﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using MMD4MecanimInternal.Bullet;
using UnityEngine;

// Token: 0x02000049 RID: 73
public class MMD4MecanimBulletPhysics : MonoBehaviour
{
	// Token: 0x1700004C RID: 76
	// (get) Token: 0x060001B8 RID: 440 RVA: 0x0000FA8E File Offset: 0x0000DC8E
	public MMD4MecanimBulletPhysics.World globalWorld
	{
		get
		{
			this._ActivateGlobalWorld();
			return this._globalWorld;
		}
	}

	// Token: 0x1700004D RID: 77
	// (get) Token: 0x060001B9 RID: 441 RVA: 0x0000FA9C File Offset: 0x0000DC9C
	public static bool isUseBulletXNA
	{
		get
		{
			return MMD4MecanimBulletPhysics._isUseBulletXNA;
		}
	}

	// Token: 0x1700004E RID: 78
	// (get) Token: 0x060001BA RID: 442 RVA: 0x0000FAA4 File Offset: 0x0000DCA4
	public static MMD4MecanimBulletPhysics instance
	{
		get
		{
			if (MMD4MecanimBulletPhysics._instance == null)
			{
				MMD4MecanimBulletPhysics._instance = (MMD4MecanimBulletPhysics)UnityEngine.Object.FindObjectOfType(typeof(MMD4MecanimBulletPhysics));
				if (MMD4MecanimBulletPhysics._instance == null)
				{
					GameObject gameObject = new GameObject("MMD4MecanimBulletPhysics");
					MMD4MecanimBulletPhysics instance = gameObject.AddComponent<MMD4MecanimBulletPhysics>();
					if (MMD4MecanimBulletPhysics._instance == null)
					{
						MMD4MecanimBulletPhysics._instance = instance;
					}
				}
				if (MMD4MecanimBulletPhysics._instance != null)
				{
					MMD4MecanimBulletPhysics._instance._Initialize();
				}
			}
			return MMD4MecanimBulletPhysics._instance;
		}
	}

	// Token: 0x060001BB RID: 443 RVA: 0x0000FB34 File Offset: 0x0000DD34
	private void _Initialize()
	{
		if (this._initialized)
		{
			return;
		}
		this._initialized = true;
		UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
		MMD4MecanimBulletPhysics._isUseBulletXNA = false;
		if (MMD4MecanimBulletPhysics._isUseBulletXNA)
		{
			if (Global.bridge == null)
			{
				Global.bridge = new MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge();
			}
			UnityEngine.Debug.Log("MMD4MecanimBulletPhysics:Awake BulletXNA.");
		}
		else
		{
			UnityEngine.Debug.Log("MMD4MecanimBulletPhysics:Awake Native Plugin.");
			MMD4MecanimBulletPhysics._InitializeEngine();
		}
		base.StartCoroutine(this.DelayedAwake());
	}

	// Token: 0x060001BC RID: 444 RVA: 0x0000FBAE File Offset: 0x0000DDAE
	private void Awake()
	{
		if (MMD4MecanimBulletPhysics._instance == null)
		{
			MMD4MecanimBulletPhysics._instance = this;
		}
		else if (MMD4MecanimBulletPhysics._instance != this)
		{
			UnityEngine.Object.Destroy(base.gameObject);
			return;
		}
		this._Initialize();
	}

	// Token: 0x060001BD RID: 445 RVA: 0x0000FBED File Offset: 0x0000DDED
	private void LateUpdate()
	{
		if (this.ignoreBulletPhysics)
		{
			return;
		}
		this._InternalUpdate();
	}

	// Token: 0x060001BE RID: 446 RVA: 0x0000FC04 File Offset: 0x0000DE04
	private void _InternalUpdate()
	{
		if (this._isAwaked)
		{
			for (int num = 0; num != this._rigidBodyList.Count; num++)
			{
				this._rigidBodyList[num].Update();
			}
			for (int num2 = 0; num2 != this._mmdModelList.Count; num2++)
			{
				this._mmdModelList[num2].Update();
			}
			MMD4MecanimBulletPhysics.World globalWorld = this.globalWorld;
			if (globalWorld != null)
			{
				globalWorld.Update(Time.deltaTime);
			}
			for (int num3 = 0; num3 != this._rigidBodyList.Count; num3++)
			{
				this._rigidBodyList[num3].LateUpdate();
			}
			for (int num4 = 0; num4 != this._mmdModelList.Count; num4++)
			{
				this._mmdModelList[num4].LateUpdate(Time.deltaTime);
			}
			MMD4MecanimBulletPhysics.DebugLog();
		}
	}

	// Token: 0x060001BF RID: 447 RVA: 0x0000FCF8 File Offset: 0x0000DEF8
	private void OnDestroy()
	{
		for (int num = 0; num != this._rigidBodyList.Count; num++)
		{
			this._rigidBodyList[num].Destroy();
		}
		for (int num2 = 0; num2 != this._mmdModelList.Count; num2++)
		{
			this._mmdModelList[num2].Destroy();
		}
		this._rigidBodyList.Clear();
		this._mmdModelList.Clear();
		if (this._globalWorld != null)
		{
			this._globalWorld.Destroy();
			this._globalWorld = null;
		}
		if (MMD4MecanimBulletPhysics._instance == this)
		{
			MMD4MecanimBulletPhysics._instance = null;
			if (!MMD4MecanimBulletPhysics._isUseBulletXNA)
			{
				MMD4MecanimBulletPhysics._FinalizeEngine();
			}
		}
	}

	// Token: 0x060001C0 RID: 448 RVA: 0x0000FDBC File Offset: 0x0000DFBC
	private IEnumerator DelayedAwake()
	{
		yield return new WaitForEndOfFrame();
		this._isAwaked = true;
		yield break;
	}

	// Token: 0x060001C1 RID: 449 RVA: 0x0000FDD8 File Offset: 0x0000DFD8
	private void _ActivateGlobalWorld()
	{
		if (this._globalWorld == null)
		{
			this._globalWorld = new MMD4MecanimBulletPhysics.World();
		}
		if (this.globalWorldProperty == null)
		{
			this.globalWorldProperty = new WorldProperty();
		}
		if (this._globalWorld.isExpired)
		{
			this._globalWorld.Create(this.globalWorldProperty);
		}
	}

	// Token: 0x060001C2 RID: 450 RVA: 0x0000FE34 File Offset: 0x0000E034
	public static void DebugLog()
	{
		if (MMD4MecanimBulletPhysics._isUseBulletXNA)
		{
			return;
		}
		IntPtr intPtr = MMD4MecanimBulletPhysics._DebugLog(1);
		if (intPtr != IntPtr.Zero)
		{
			UnityEngine.Debug.Log(Marshal.PtrToStringUni(intPtr));
		}
	}

	// Token: 0x060001C3 RID: 451 RVA: 0x0000FE70 File Offset: 0x0000E070
	public MMD4MecanimBulletPhysics.MMDModel CreateMMDModel(MMD4MecanimModel model)
	{
		MMD4MecanimBulletPhysics.MMDModel mmdmodel = new MMD4MecanimBulletPhysics.MMDModel();
		if (!mmdmodel.Create(model))
		{
			UnityEngine.Debug.LogError("CreateMMDModel: Failed " + model.gameObject.name);
			return null;
		}
		this._mmdModelList.Add(mmdmodel);
		return mmdmodel;
	}

	// Token: 0x060001C4 RID: 452 RVA: 0x0000FEB8 File Offset: 0x0000E0B8
	public void DestroyMMDModel(MMD4MecanimBulletPhysics.MMDModel mmdModel)
	{
		for (int i = 0; i < this._mmdModelList.Count; i++)
		{
			if (this._mmdModelList[i] == mmdModel)
			{
				mmdModel.Destroy();
				this._mmdModelList.Remove(mmdModel);
				return;
			}
		}
	}

	// Token: 0x060001C5 RID: 453 RVA: 0x0000FF08 File Offset: 0x0000E108
	public MMD4MecanimBulletPhysics.RigidBody CreateRigidBody(MMD4MecanimRigidBody rigidBody)
	{
		MMD4MecanimBulletPhysics.RigidBody rigidBody2 = new MMD4MecanimBulletPhysics.RigidBody();
		if (!rigidBody2.Create(rigidBody))
		{
			return null;
		}
		this._rigidBodyList.Add(rigidBody2);
		return rigidBody2;
	}

	// Token: 0x060001C6 RID: 454 RVA: 0x0000FF38 File Offset: 0x0000E138
	public void DestroyRigidBody(MMD4MecanimBulletPhysics.RigidBody rigidBody)
	{
		for (int i = 0; i < this._rigidBodyList.Count; i++)
		{
			if (this._rigidBodyList[i] == rigidBody)
			{
				rigidBody.Destroy();
				this._rigidBodyList.Remove(rigidBody);
				return;
			}
		}
	}

	// Token: 0x060001C7 RID: 455 RVA: 0x0000FF87 File Offset: 0x0000E187
	private static void _InitializeEngine()
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsInitialize();
	}

	// Token: 0x060001C8 RID: 456 RVA: 0x0000FF8E File Offset: 0x0000E18E
	private static void _FinalizeEngine()
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsFinalize();
	}

	// Token: 0x060001C9 RID: 457 RVA: 0x0000FF95 File Offset: 0x0000E195
	private static IntPtr _DebugLog(int clanupFlag)
	{
		return MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsDebugLog(clanupFlag);
	}

	// Token: 0x060001CA RID: 458 RVA: 0x0000FF9D File Offset: 0x0000E19D
	private static IntPtr _CreateWorld(IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		return MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsCreateWorld(iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001CB RID: 459 RVA: 0x0000FFA8 File Offset: 0x0000E1A8
	private static void _ConfigWorld(IntPtr worldPtr, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsConfigWorld(worldPtr, iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001CC RID: 460 RVA: 0x0000FFB5 File Offset: 0x0000E1B5
	private static void _DestroyWorld(IntPtr worldPtr)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsDestroyWorld(worldPtr);
	}

	// Token: 0x060001CD RID: 461 RVA: 0x0000FFBD File Offset: 0x0000E1BD
	private static void _UpdateWorld(IntPtr worldPtr, float deltaTime, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsUpdateWorld(worldPtr, deltaTime, iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001CE RID: 462 RVA: 0x0000FFCC File Offset: 0x0000E1CC
	private static IntPtr _CreateRigidBody(IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		return MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsCreateRigidBody(iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001CF RID: 463 RVA: 0x0000FFD7 File Offset: 0x0000E1D7
	private static void _ConfigRigidBody(IntPtr rigidBodyPtr, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsConfigRigidBody(rigidBodyPtr, iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001D0 RID: 464 RVA: 0x0000FFE4 File Offset: 0x0000E1E4
	private static void _DestroyRigidBody(IntPtr rigidBodyPtr)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsDestroyRigidBody(rigidBodyPtr);
	}

	// Token: 0x060001D1 RID: 465 RVA: 0x0000FFEC File Offset: 0x0000E1EC
	private static void _JoinWorldRigidBody(IntPtr worldPtr, IntPtr rigidBodyPtr)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsJoinWorldRigidBody(worldPtr, rigidBodyPtr);
	}

	// Token: 0x060001D2 RID: 466 RVA: 0x0000FFF5 File Offset: 0x0000E1F5
	private static void _LeaveWorldRigidBody(IntPtr rigidBodyPtr)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsLeaveWorldRigidBody(rigidBodyPtr);
	}

	// Token: 0x060001D3 RID: 467 RVA: 0x0000FFFD File Offset: 0x0000E1FD
	private static void _ResetWorldRigidBody(IntPtr rigidBodyPtr)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsResetWorldRigidBody(rigidBodyPtr);
	}

	// Token: 0x060001D4 RID: 468 RVA: 0x00010005 File Offset: 0x0000E205
	private static void _UpdateRigidBody(IntPtr rigidBodyPtr, int updateFlags, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsUpdateRigidBody(rigidBodyPtr, updateFlags, iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001D5 RID: 469 RVA: 0x00010014 File Offset: 0x0000E214
	private static int _LateUpdateRigidBody(IntPtr rigidBodyPtr, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		return MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsLateUpdateRigidBody(rigidBodyPtr, iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001D6 RID: 470 RVA: 0x00010024 File Offset: 0x0000E224
	private static IntPtr _CreateMMDModel(IntPtr mmdModelBytes, int mmdModelLength, IntPtr mmdIndexBytes, int mmdIndexLength, IntPtr mmdVertexBytes, int mmdVertexLength, IntPtr iMeshValues, int meshLength, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		return MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsCreateMMDModel(mmdModelBytes, mmdModelLength, mmdIndexBytes, mmdIndexLength, mmdVertexBytes, mmdVertexLength, iMeshValues, meshLength, iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001D7 RID: 471 RVA: 0x0001004A File Offset: 0x0000E24A
	private static int _GetFullBodyIKDataMMDModel(IntPtr mmdModelPtr, IntPtr fullBodyIKBoneID, IntPtr fullBodyIKPositions, IntPtr fullBodyIKRotations, int fullBodyIKLength)
	{
		return MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsGetFullBodyIKDataMMDModel(mmdModelPtr, fullBodyIKBoneID, fullBodyIKPositions, fullBodyIKRotations, fullBodyIKLength);
	}

	// Token: 0x060001D8 RID: 472 RVA: 0x00010057 File Offset: 0x0000E257
	private static int _UploadMeshMMDModel(IntPtr mmdModelPtr, int meshID, IntPtr vertices, IntPtr normals, IntPtr boneWeights, int vertexLength, IntPtr bindposes, int boneLength)
	{
		return MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsUploadMeshMMDModel(mmdModelPtr, meshID, vertices, normals, boneWeights, vertexLength, bindposes, boneLength);
	}

	// Token: 0x060001D9 RID: 473 RVA: 0x0001006A File Offset: 0x0000E26A
	private static void _ConfigMMDModel(IntPtr mmdModelPtr, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsConfigMMDModel(mmdModelPtr, iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001DA RID: 474 RVA: 0x00010077 File Offset: 0x0000E277
	private static void _DestroyMMDModel(IntPtr mmdModelPtr)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsDestroyMMDModel(mmdModelPtr);
	}

	// Token: 0x060001DB RID: 475 RVA: 0x0001007F File Offset: 0x0000E27F
	private static void _JoinWorldMMDModel(IntPtr worldPtr, IntPtr mmdModelPtr)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsJoinWorldMMDModel(worldPtr, mmdModelPtr);
	}

	// Token: 0x060001DC RID: 476 RVA: 0x00010088 File Offset: 0x0000E288
	private static void _LeaveWorldMMDModel(IntPtr mmdModelPtr)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsLeaveWorldMMDModel(mmdModelPtr);
	}

	// Token: 0x060001DD RID: 477 RVA: 0x00010090 File Offset: 0x0000E290
	private static void _ResetWorldMMDModel(IntPtr mmdModelPtr)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsResetWorldMMDModel(mmdModelPtr);
	}

	// Token: 0x060001DE RID: 478 RVA: 0x00010098 File Offset: 0x0000E298
	private static int _PreUpdateMMDModel(IntPtr mmdModelPtr, int updateFlags, IntPtr iBoneValues, int boneLength, IntPtr iRigidBodyValues, int rigidBodyLength, IntPtr ikWeights, int ikLength, IntPtr morphWeights, int morphLength, IntPtr iFullBodyIKValues, IntPtr fullBodyIKWeights, int fullBodyIKLength)
	{
		return MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsPreUpdateMMDModel(mmdModelPtr, updateFlags, iBoneValues, boneLength, iRigidBodyValues, rigidBodyLength, ikWeights, ikLength, morphWeights, morphLength, iFullBodyIKValues, fullBodyIKWeights, fullBodyIKLength);
	}

	// Token: 0x060001DF RID: 479 RVA: 0x000100C0 File Offset: 0x0000E2C0
	private static void _UpdateMMDModel(IntPtr mmdModelPtr, int updateFlags, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength, IntPtr modelTransform, IntPtr iBoneValues, IntPtr boneTransforms, IntPtr boneLocalPositions, IntPtr boneLocalRotations, IntPtr boneUserPositions, IntPtr boneUserRotations, int boneLength, IntPtr iRigidBodyValues, int rigidBodyLength, IntPtr ikWeights, int ikLength, IntPtr morphWeights, int morphLength, IntPtr iFullBodyIKValues, IntPtr fullBodyIKTransforms, IntPtr fullBodyIKWeights, int fullBodyIKLength)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsUpdateMMDModel(mmdModelPtr, updateFlags, iValues, iValueLength, fValues, fValueLength, modelTransform, iBoneValues, boneTransforms, boneLocalPositions, boneLocalRotations, boneUserPositions, boneUserRotations, boneLength, iRigidBodyValues, rigidBodyLength, ikWeights, ikLength, morphWeights, morphLength, iFullBodyIKValues, fullBodyIKTransforms, fullBodyIKWeights, fullBodyIKLength);
	}

	// Token: 0x060001E0 RID: 480 RVA: 0x00010100 File Offset: 0x0000E300
	private static int _LateUpdateMMDModel(IntPtr mmdModelPtr, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength, IntPtr iBoneValues, IntPtr bonePositions, IntPtr boneRotations, int boneLength, IntPtr iMeshValues, int meshLength, IntPtr morphWeigts, int morphLength)
	{
		return MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsLateUpdateMMDModel(mmdModelPtr, iValues, iValueLength, fValues, fValueLength, iBoneValues, bonePositions, boneRotations, boneLength, iMeshValues, meshLength, morphWeigts, morphLength);
	}

	// Token: 0x060001E1 RID: 481 RVA: 0x00010128 File Offset: 0x0000E328
	private static int _LateUpdateMeshMMDModel(IntPtr mmdModelPtr, int meshID, IntPtr vertices, IntPtr normals, int vertexLength)
	{
		return MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsLateUpdateMeshMMDModel(mmdModelPtr, meshID, vertices, normals, vertexLength);
	}

	// Token: 0x060001E2 RID: 482 RVA: 0x00010135 File Offset: 0x0000E335
	private static void _ConfigBoneMMDModel(IntPtr mmdModelPtr, int boneID, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsConfigBoneMMDModel(mmdModelPtr, boneID, iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001E3 RID: 483 RVA: 0x00010144 File Offset: 0x0000E344
	private static void _ConfigRigidBodyMMDModel(IntPtr mmdModelPtr, int rigidBodyID, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsConfigRigidBodyMMDModel(mmdModelPtr, rigidBodyID, iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001E4 RID: 484 RVA: 0x00010153 File Offset: 0x0000E353
	private static void _ConfigJointMMDModel(IntPtr mmdModelPtr, int jointID, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength)
	{
		MMD4MecanimBulletPhysics.MMD4MecanimBulletPhysicsConfigJointMMDModel(mmdModelPtr, jointID, iValues, iValueLength, fValues, fValueLength);
	}

	// Token: 0x060001E5 RID: 485
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsInitialize();

	// Token: 0x060001E6 RID: 486
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsFinalize();

	// Token: 0x060001E7 RID: 487
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern IntPtr MMD4MecanimBulletPhysicsDebugLog(int clanupFlag);

	// Token: 0x060001E8 RID: 488
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern IntPtr MMD4MecanimBulletPhysicsCreateWorld(IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x060001E9 RID: 489
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsConfigWorld(IntPtr worldPtr, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x060001EA RID: 490
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsDestroyWorld(IntPtr worldPtr);

	// Token: 0x060001EB RID: 491
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsUpdateWorld(IntPtr worldPtr, float deltaTime, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x060001EC RID: 492
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern IntPtr MMD4MecanimBulletPhysicsCreateRigidBody(IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x060001ED RID: 493
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsConfigRigidBody(IntPtr rigidBodyPtr, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x060001EE RID: 494
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsDestroyRigidBody(IntPtr rigidBodyPtr);

	// Token: 0x060001EF RID: 495
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsJoinWorldRigidBody(IntPtr worldPtr, IntPtr rigidBodyPtr);

	// Token: 0x060001F0 RID: 496
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsLeaveWorldRigidBody(IntPtr rigidBodyPtr);

	// Token: 0x060001F1 RID: 497
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsResetWorldRigidBody(IntPtr rigidBodyPtr);

	// Token: 0x060001F2 RID: 498
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsUpdateRigidBody(IntPtr rigidBodyPtr, int updateFlags, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x060001F3 RID: 499
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern int MMD4MecanimBulletPhysicsLateUpdateRigidBody(IntPtr rigidBodyPtr, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x060001F4 RID: 500
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern IntPtr MMD4MecanimBulletPhysicsCreateMMDModel(IntPtr mmdModelBytes, int mmdModelLength, IntPtr mmdIndexBytes, int mmdIndexLength, IntPtr mmdVertexBytes, int mmdVertexLength, IntPtr iMeshValues, int meshLength, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x060001F5 RID: 501
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern int MMD4MecanimBulletPhysicsGetFullBodyIKDataMMDModel(IntPtr mmdModelPtr, IntPtr fullBodyIKBoneID, IntPtr fullBodyIKPositions, IntPtr fullBodyIKRotations, int fullBodyIKLength);

	// Token: 0x060001F6 RID: 502
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern int MMD4MecanimBulletPhysicsUploadMeshMMDModel(IntPtr mmdModelPtr, int meshID, IntPtr vertices, IntPtr normals, IntPtr boneWeights, int vertexLength, IntPtr bindposes, int boneLength);

	// Token: 0x060001F7 RID: 503
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsConfigMMDModel(IntPtr mmdModelPtr, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x060001F8 RID: 504
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsDestroyMMDModel(IntPtr mmdModelPtr);

	// Token: 0x060001F9 RID: 505
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsJoinWorldMMDModel(IntPtr worldPtr, IntPtr mmdModelPtr);

	// Token: 0x060001FA RID: 506
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsLeaveWorldMMDModel(IntPtr mmdModelPtr);

	// Token: 0x060001FB RID: 507
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsResetWorldMMDModel(IntPtr mmdModelPtr);

	// Token: 0x060001FC RID: 508
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern int MMD4MecanimBulletPhysicsPreUpdateMMDModel(IntPtr mmdModelPtr, int updateFlags, IntPtr iBoneValues, int boneLength, IntPtr iRigidBodyValues, int rigidBodyLength, IntPtr ikWeights, int ikLength, IntPtr morphWeights, int morphLength, IntPtr iFullBodyIKValues, IntPtr fullBodyIKWeights, int fullBodyIKLength);

	// Token: 0x060001FD RID: 509
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsUpdateMMDModel(IntPtr mmdModelPtr, int updateFlags, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength, IntPtr modelTransform, IntPtr iBoneValues, IntPtr boneTransforms, IntPtr boneLocalPositions, IntPtr boneLocalRotations, IntPtr boneUserPositions, IntPtr boneUserRotations, int boneLength, IntPtr iRigidBodyValues, int rigidBodyLength, IntPtr ikWeights, int ikLength, IntPtr morphWeights, int morphLength, IntPtr iFullBodyIKValues, IntPtr fullBodyIKTransforms, IntPtr fullBodyIKWeights, int fullBodyIKLength);

	// Token: 0x060001FE RID: 510
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern int MMD4MecanimBulletPhysicsLateUpdateMMDModel(IntPtr mmdModelPtr, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength, IntPtr iBoneValues, IntPtr bonePositions, IntPtr boneRotations, int boneLength, IntPtr iMeshValues, int meshLength, IntPtr morphWeigts, int morphLength);

	// Token: 0x060001FF RID: 511
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern int MMD4MecanimBulletPhysicsLateUpdateMeshMMDModel(IntPtr mmdModelPtr, int meshID, IntPtr vertices, IntPtr normals, int vertexLength);

	// Token: 0x06000200 RID: 512
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsConfigBoneMMDModel(IntPtr mmdModelPtr, int boneID, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x06000201 RID: 513
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsConfigRigidBodyMMDModel(IntPtr mmdModelPtr, int rigidBodyID, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x06000202 RID: 514
	[DllImport("MMD4MecanimBulletPhysics")]
	public static extern void MMD4MecanimBulletPhysicsConfigJointMMDModel(IntPtr mmdModelPtr, int jointID, IntPtr iValues, int iValueLength, IntPtr fValues, int fValueLength);

	// Token: 0x04000274 RID: 628
	public static readonly Matrix4x4 rotateMatrixX = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, 90f), Vector3.one);

	// Token: 0x04000275 RID: 629
	public static readonly Matrix4x4 rotateMatrixXInv = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, -90f), Vector3.one);

	// Token: 0x04000276 RID: 630
	public static readonly Matrix4x4 rotateMatrixZ = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(90f, 0f, 0f), Vector3.one);

	// Token: 0x04000277 RID: 631
	public static readonly Matrix4x4 rotateMatrixZInv = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90f, 0f, 0f), Vector3.one);

	// Token: 0x04000278 RID: 632
	public static readonly Quaternion rotateQuaternionX = Quaternion.Euler(0f, 0f, 90f);

	// Token: 0x04000279 RID: 633
	public static readonly Quaternion rotateQuaternionZ = Quaternion.Euler(90f, 0f, 0f);

	// Token: 0x0400027A RID: 634
	public static readonly Quaternion rotateQuaternionXInv = Quaternion.Euler(0f, 0f, -90f);

	// Token: 0x0400027B RID: 635
	public static readonly Quaternion rotateQuaternionZInv = Quaternion.Euler(-90f, 0f, 0f);

	// Token: 0x0400027C RID: 636
	public WorldProperty globalWorldProperty;

	// Token: 0x0400027D RID: 637
	private List<MMD4MecanimBulletPhysics.MMDModel> _mmdModelList = new List<MMD4MecanimBulletPhysics.MMDModel>();

	// Token: 0x0400027E RID: 638
	private List<MMD4MecanimBulletPhysics.RigidBody> _rigidBodyList = new List<MMD4MecanimBulletPhysics.RigidBody>();

	// Token: 0x0400027F RID: 639
	private bool _isAwaked;

	// Token: 0x04000280 RID: 640
	private MMD4MecanimBulletPhysics.World _globalWorld;

	// Token: 0x04000281 RID: 641
	private static MMD4MecanimBulletPhysics _instance;

	// Token: 0x04000282 RID: 642
	private bool _initialized;

	// Token: 0x04000283 RID: 643
	private static bool _isUseBulletXNA;

	// Token: 0x04000284 RID: 644
	private Process _process;

	// Token: 0x04000285 RID: 645
	private bool ignoreBulletPhysics = true;

	// Token: 0x04000286 RID: 646
	public const string DllName = "MMD4MecanimBulletPhysics";

	// Token: 0x0200004A RID: 74
	public class MMD4MecanimBulletBridge : IBridge
	{
		// Token: 0x06000205 RID: 517 RVA: 0x00010275 File Offset: 0x0000E475
		object IBridge.CreateCachedThreadQueue(int maxThreads)
		{
			return new MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue(maxThreads);
		}

		// Token: 0x06000206 RID: 518 RVA: 0x00010280 File Offset: 0x0000E480
		ThreadQueueHandle IBridge.InvokeCachedThreadQueue(object cachedThreadQueue, Action action)
		{
			if (cachedThreadQueue != null)
			{
				return ((MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue)cachedThreadQueue).Invoke(action);
			}
			return default(ThreadQueueHandle);
		}

		// Token: 0x06000207 RID: 519 RVA: 0x000102A9 File Offset: 0x0000E4A9
		void IBridge.WaitEndCachedThreadQueue(object cachedThreadQueue, ref ThreadQueueHandle threadQueueHandle)
		{
			if (cachedThreadQueue != null)
			{
				((MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue)cachedThreadQueue).WaitEnd(ref threadQueueHandle);
			}
		}

		// Token: 0x06000208 RID: 520 RVA: 0x000102BD File Offset: 0x0000E4BD
		object IBridge.CreatePararellCachedThreadQueue(int maxThreads)
		{
			return new MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue(maxThreads);
		}

		// Token: 0x06000209 RID: 521 RVA: 0x000102C8 File Offset: 0x0000E4C8
		ThreadQueueHandle IBridge.InvokeCachedPararellThreadQueue(object cachedPararellThreadQueue, PararellFunction function, int length)
		{
			if (cachedPararellThreadQueue != null)
			{
				return ((MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue)cachedPararellThreadQueue).Invoke(function, length);
			}
			return default(ThreadQueueHandle);
		}

		// Token: 0x0600020A RID: 522 RVA: 0x000102F2 File Offset: 0x0000E4F2
		void IBridge.WaitEndCachedPararellThreadQueue(object cachedPararellThreadQueue, ref ThreadQueueHandle threadQueueHandle)
		{
			if (cachedPararellThreadQueue != null)
			{
				((MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue)cachedPararellThreadQueue).WaitEnd(ref threadQueueHandle);
			}
		}

		// Token: 0x0600020B RID: 523 RVA: 0x00010306 File Offset: 0x0000E506
		public static void InstantSleep()
		{
			Thread.Sleep(0);
		}

		// Token: 0x0600020C RID: 524 RVA: 0x0001030E File Offset: 0x0000E50E
		public static void ShortlySleep()
		{
			Thread.Sleep(1);
		}

		// Token: 0x0600020D RID: 525 RVA: 0x00010316 File Offset: 0x0000E516
		public static int GetProcessCount()
		{
			return 4;
		}

		// Token: 0x0200004B RID: 75
		public class CachedThreadQueue
		{
			// Token: 0x0600020E RID: 526 RVA: 0x0001031C File Offset: 0x0000E51C
			public CachedThreadQueue()
			{
				this._maxThreads = MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.GetProcessCount();
			}

			// Token: 0x0600020F RID: 527 RVA: 0x00010380 File Offset: 0x0000E580
			public CachedThreadQueue(int maxThreads)
			{
				this._maxThreads = maxThreads;
				if (this._maxThreads <= 0)
				{
					this._maxThreads = Mathf.Max(MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.GetProcessCount(), 1);
				}
			}

			// Token: 0x06000210 RID: 528 RVA: 0x000103FC File Offset: 0x0000E5FC
			private static MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue.Queue _FindQueue(ArrayList queues, ref ThreadQueueHandle queueHandle)
			{
				if (queues != null)
				{
					for (int num = 0; num != queues.Count; num++)
					{
						MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue.Queue queue = (MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue.Queue)queues[num];
						if (queue == queueHandle.queuePtr && queue.queueID == queueHandle.queueID)
						{
							return queue;
						}
					}
				}
				return null;
			}

			// Token: 0x06000211 RID: 529 RVA: 0x00010454 File Offset: 0x0000E654
			~CachedThreadQueue()
			{
				if (this._threads.Count != 0)
				{
					this._Finalize();
				}
			}

			// Token: 0x06000212 RID: 530 RVA: 0x00010494 File Offset: 0x0000E694
			public void _Finalize()
			{
				this._lockMutex.WaitOne();
				bool isFinalized = this._isFinalized;
				this._isFinalized = true;
				if (!isFinalized)
				{
					this._invokeEvent.Set();
				}
				this._lockMutex.ReleaseMutex();
				if (isFinalized)
				{
					return;
				}
				for (int num = 0; num != this._threads.Count; num++)
				{
					((Thread)this._threads[num]).Join();
				}
				this._threads.Clear();
				this._lockMutex.WaitOne();
				this._isFinalized = false;
				this._lockMutex.ReleaseMutex();
			}

			// Token: 0x06000213 RID: 531 RVA: 0x0001053C File Offset: 0x0000E73C
			public ThreadQueueHandle Invoke(Action function)
			{
				ThreadQueueHandle result = default(ThreadQueueHandle);
				if (function == null)
				{
					return result;
				}
				this._lockMutex.WaitOne();
				bool isFinalized = this._isFinalized;
				if (!isFinalized)
				{
					int count = this._processingQueues.Count;
					if (count == this._threads.Count && this._threads.Count < this._maxThreads)
					{
						Thread thread = new Thread(new ThreadStart(this._Run));
						this._threads.Add(thread);
						thread.Start();
					}
					MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue.Queue queue = null;
					for (int i = this._unusedQueues.Count - 1; i >= 0; i--)
					{
						queue = (MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue.Queue)this._unusedQueues[i];
						if (!queue.processingWaitEnd)
						{
							this._unusedQueues.RemoveAt(i);
							queue.Reuse(function);
							break;
						}
						queue = null;
					}
					if (queue == null)
					{
						queue = new MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue.Queue(function);
					}
					queue.uniqueID = this._uniqueID;
					this._uniqueID += 1U;
					this._reservedQueues.Add(queue);
					result.queuePtr = queue;
					result.queueID = queue.queueID;
					result.uniqueID = queue.uniqueID;
					this._invokeEvent.Set();
				}
				this._lockMutex.ReleaseMutex();
				if (isFinalized)
				{
					function();
				}
				return result;
			}

			// Token: 0x06000214 RID: 532 RVA: 0x000106B4 File Offset: 0x0000E8B4
			public void WaitEnd(ref ThreadQueueHandle queueHandle)
			{
				if (queueHandle.queuePtr == null)
				{
					return;
				}
				this._lockMutex.WaitOne();
				MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue.Queue queue = MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue._FindQueue(this._processingQueues, ref queueHandle);
				if (queue == null)
				{
					queue = MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue._FindQueue(this._reservedQueues, ref queueHandle);
				}
				if (queue != null)
				{
					queue.processingWaitEnd = true;
				}
				this._lockMutex.ReleaseMutex();
				if (queue == null)
				{
					queueHandle.Reset();
					return;
				}
				do
				{
					MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.InstantSleep();
					queue.processedEvent.WaitOne();
					this._lockMutex.WaitOne();
					if (queue.queueID != queueHandle.queueID)
					{
						queue.processingWaitEnd = false;
						queue = null;
					}
					this._lockMutex.ReleaseMutex();
				}
				while (queue != null);
				queueHandle.Reset();
			}

			// Token: 0x06000215 RID: 533 RVA: 0x00010780 File Offset: 0x0000E980
			private void _Run()
			{
				for (;;)
				{
					MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue.Queue queue = null;
					this._invokeEvent.WaitOne();
					this._lockMutex.WaitOne();
					if (this._reservedQueues.Count != 0)
					{
						queue = (MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedThreadQueue.Queue)this._reservedQueues[0];
						this._reservedQueues.RemoveAt(0);
						this._processingQueues.Add(queue);
					}
					bool flag = queue != null;
					bool isFinalized = this._isFinalized;
					bool flag2 = this._processingQueues.Count == 0 && this._reservedQueues.Count == 0;
					this._lockMutex.ReleaseMutex();
					if (queue != null)
					{
						if (queue.function != null)
						{
							queue.function();
						}
						this._lockMutex.WaitOne();
						queue.Unuse();
						this._processingQueues.Remove(queue);
						this._unusedQueues.Add(queue);
						queue.processedEvent.Set();
						isFinalized = this._isFinalized;
						flag2 = (this._processingQueues.Count == 0 && this._reservedQueues.Count == 0);
						if (flag2)
						{
							this._invokeEvent.Reset();
						}
						this._lockMutex.ReleaseMutex();
					}
					if (flag2 && isFinalized)
					{
						break;
					}
					if (!flag)
					{
						MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.InstantSleep();
					}
				}
			}

			// Token: 0x04000287 RID: 647
			private Mutex _lockMutex = new Mutex();

			// Token: 0x04000288 RID: 648
			private ManualResetEvent _invokeEvent = new ManualResetEvent(false);

			// Token: 0x04000289 RID: 649
			private ArrayList _threads = new ArrayList();

			// Token: 0x0400028A RID: 650
			private int _maxThreads;

			// Token: 0x0400028B RID: 651
			private bool _isFinalized;

			// Token: 0x0400028C RID: 652
			private uint _uniqueID;

			// Token: 0x0400028D RID: 653
			private ArrayList _processingQueues = new ArrayList();

			// Token: 0x0400028E RID: 654
			private ArrayList _reservedQueues = new ArrayList();

			// Token: 0x0400028F RID: 655
			private ArrayList _unusedQueues = new ArrayList();

			// Token: 0x0200004C RID: 76
			private class Queue
			{
				// Token: 0x06000216 RID: 534 RVA: 0x000108E5 File Offset: 0x0000EAE5
				public Queue(Action function)
				{
					this.function = function;
					this.queueID = 0U;
					this.uniqueID = 0U;
					this.processedEvent = new ManualResetEvent(false);
				}

				// Token: 0x06000217 RID: 535 RVA: 0x0001090E File Offset: 0x0000EB0E
				public void Unuse()
				{
					this.function = null;
					this.queueID += 1U;
				}

				// Token: 0x06000218 RID: 536 RVA: 0x00010925 File Offset: 0x0000EB25
				public void Reuse(Action function)
				{
					this.function = function;
					this.processedEvent.Reset();
				}

				// Token: 0x04000290 RID: 656
				public Action function;

				// Token: 0x04000291 RID: 657
				public uint queueID;

				// Token: 0x04000292 RID: 658
				public uint uniqueID;

				// Token: 0x04000293 RID: 659
				public bool processingWaitEnd;

				// Token: 0x04000294 RID: 660
				public ManualResetEvent processedEvent;
			}
		}

		// Token: 0x0200004D RID: 77
		public class CachedPararellThreadQueue
		{
			// Token: 0x06000219 RID: 537 RVA: 0x0001093C File Offset: 0x0000EB3C
			public CachedPararellThreadQueue()
			{
				this._maxThreads = MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.GetProcessCount();
			}

			// Token: 0x0600021A RID: 538 RVA: 0x00010994 File Offset: 0x0000EB94
			public CachedPararellThreadQueue(int maxThreads)
			{
				this._maxThreads = maxThreads;
				if (this._maxThreads <= 0)
				{
					this._maxThreads = Mathf.Max(MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.GetProcessCount(), 1);
				}
			}

			// Token: 0x0600021B RID: 539 RVA: 0x00010A03 File Offset: 0x0000EC03
			private static bool _IsEqualQueue(MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue queue, ref ThreadQueueHandle queueHandle)
			{
				return queue != null && queue == queueHandle.queuePtr && queue.queueID == queueHandle.queueID;
			}

			// Token: 0x0600021C RID: 540 RVA: 0x00010A2C File Offset: 0x0000EC2C
			private static MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue _FindQueue(ArrayList queues, ref ThreadQueueHandle queueHandle)
			{
				if (queues != null)
				{
					for (int num = 0; num != queues.Count; num++)
					{
						MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue queue = (MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue)queues[num];
						if (queue == queueHandle.queuePtr && queue.queueID == queueHandle.queueID)
						{
							return queue;
						}
					}
				}
				return null;
			}

			// Token: 0x0600021D RID: 541 RVA: 0x00010A84 File Offset: 0x0000EC84
			private void _AwakeThread()
			{
				if (this._threads == null)
				{
					this._threads = new Thread[this._maxThreads];
					for (int num = 0; num != this._maxThreads; num++)
					{
						Thread thread = new Thread(new ThreadStart(this._Run));
						this._threads[num] = thread;
						thread.Start();
					}
				}
			}

			// Token: 0x0600021E RID: 542 RVA: 0x00010AE8 File Offset: 0x0000ECE8
			~CachedPararellThreadQueue()
			{
				if (this._threads != null)
				{
					this._Finalize();
				}
			}

			// Token: 0x0600021F RID: 543 RVA: 0x00010B24 File Offset: 0x0000ED24
			public void _Finalize()
			{
				this._lockMutex.WaitOne();
				bool isFinalized = this._isFinalized;
				this._isFinalized = true;
				if (!isFinalized)
				{
					this._invokeEvent.Set();
				}
				this._lockMutex.ReleaseMutex();
				if (isFinalized)
				{
					return;
				}
				if (this._threads != null)
				{
					for (int num = 0; num != this._threads.Length; num++)
					{
						this._threads[num].Join();
					}
					this._threads = null;
				}
				this._lockMutex.WaitOne();
				this._isFinalized = false;
				this._lockMutex.ReleaseMutex();
			}

			// Token: 0x06000220 RID: 544 RVA: 0x00010BC8 File Offset: 0x0000EDC8
			public ThreadQueueHandle Invoke(PararellFunction function, int length)
			{
				ThreadQueueHandle result = default(ThreadQueueHandle);
				if (function == null)
				{
					return result;
				}
				this._lockMutex.WaitOne();
				bool isFinalized = this._isFinalized;
				if (!isFinalized)
				{
					this._AwakeThread();
					MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue queue = null;
					for (int i = this._unusedQueues.Count - 1; i >= 0; i--)
					{
						queue = (MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue)this._unusedQueues[i];
						if (!queue.processingWaitEnd)
						{
							this._unusedQueues.RemoveAt(i);
							queue.Reuse(function, length);
							break;
						}
						queue = null;
					}
					if (queue == null)
					{
						queue = new MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue(function, length);
					}
					queue.uniqueID = this._uniqueID;
					this._uniqueID += 1U;
					this._reservedQueues.Add(queue);
					result.queuePtr = queue;
					result.queueID = queue.queueID;
					result.uniqueID = queue.uniqueID;
					this._invokeEvent.Set();
				}
				this._lockMutex.ReleaseMutex();
				if (isFinalized)
				{
					function(0, length);
				}
				return result;
			}

			// Token: 0x06000221 RID: 545 RVA: 0x00010CE0 File Offset: 0x0000EEE0
			public void WaitEnd(ref ThreadQueueHandle queueHandle)
			{
				if (queueHandle.queuePtr == null)
				{
					return;
				}
				this._lockMutex.WaitOne();
				MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue queue = MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue._FindQueue(this._processedQueues, ref queueHandle);
				if (queue == null)
				{
					if (MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue._IsEqualQueue(this._processingQueue, ref queueHandle))
					{
						queue = this._processingQueue;
					}
					else
					{
						queue = MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue._FindQueue(this._reservedQueues, ref queueHandle);
					}
				}
				if (queue != null)
				{
					queue.processingWaitEnd = true;
				}
				this._lockMutex.ReleaseMutex();
				if (queue == null)
				{
					queueHandle.Reset();
					return;
				}
				do
				{
					MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.InstantSleep();
					queue.processedEvent.WaitOne();
					this._lockMutex.WaitOne();
					if (queue.queueID != queueHandle.queueID)
					{
						queue.processingWaitEnd = false;
						queue = null;
					}
					this._lockMutex.ReleaseMutex();
				}
				while (queue != null);
				queueHandle.Reset();
			}

			// Token: 0x06000222 RID: 546 RVA: 0x00010DC8 File Offset: 0x0000EFC8
			private void _Run()
			{
				for (;;)
				{
					MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue queue = null;
					int num = 0;
					this._invokeEvent.WaitOne();
					this._lockMutex.WaitOne();
					if (this._processingQueue != null)
					{
						queue = this._processingQueue;
					}
					else if (this._reservedQueues.Count != 0)
					{
						queue = (MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue)this._reservedQueues[0];
						this._reservedQueues.RemoveAt(0);
						this._processingQueue = queue;
					}
					if (queue != null)
					{
						num = queue.processingThreads;
						queue.processingThreads++;
						if (queue.processingThreads == this._maxThreads)
						{
							this._processingQueue = null;
							this._processedQueues.Add(queue);
						}
					}
					bool flag = queue != null;
					bool isFinalized = this._isFinalized;
					bool flag2 = this._processingQueue == null && this._reservedQueues.Count == 0;
					this._lockMutex.ReleaseMutex();
					if (queue != null)
					{
						int num2 = (queue.length + this._maxThreads - 1) / this._maxThreads;
						int num3 = num * num2;
						if (num3 < queue.length)
						{
							if (num3 + num2 > queue.length)
							{
								num2 = queue.length - num3;
							}
							if (queue.function != null)
							{
								queue.function(num3, num2);
							}
						}
						this._lockMutex.WaitOne();
						if (++queue.processedThreads == this._maxThreads)
						{
							queue.Unuse();
							this._processedQueues.Remove(queue);
							this._unusedQueues.Add(queue);
							queue.processedEvent.Set();
							isFinalized = this._isFinalized;
							flag2 = (this._processingQueue == null && this._reservedQueues.Count == 0);
							if (flag2)
							{
								this._invokeEvent.Reset();
							}
						}
						this._lockMutex.ReleaseMutex();
					}
					if (flag2 && isFinalized)
					{
						break;
					}
					if (!flag)
					{
						MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.InstantSleep();
					}
				}
			}

			// Token: 0x04000295 RID: 661
			private Mutex _lockMutex = new Mutex();

			// Token: 0x04000296 RID: 662
			private ManualResetEvent _invokeEvent = new ManualResetEvent(false);

			// Token: 0x04000297 RID: 663
			private Thread[] _threads;

			// Token: 0x04000298 RID: 664
			private int _maxThreads;

			// Token: 0x04000299 RID: 665
			private bool _isFinalized;

			// Token: 0x0400029A RID: 666
			private uint _uniqueID;

			// Token: 0x0400029B RID: 667
			private ArrayList _processedQueues = new ArrayList();

			// Token: 0x0400029C RID: 668
			private MMD4MecanimBulletPhysics.MMD4MecanimBulletBridge.CachedPararellThreadQueue.Queue _processingQueue;

			// Token: 0x0400029D RID: 669
			private ArrayList _reservedQueues = new ArrayList();

			// Token: 0x0400029E RID: 670
			private ArrayList _unusedQueues = new ArrayList();

			// Token: 0x0200004E RID: 78
			private class Queue
			{
				// Token: 0x06000223 RID: 547 RVA: 0x00010FE3 File Offset: 0x0000F1E3
				public Queue(PararellFunction function, int length)
				{
					this.function = function;
					this.length = length;
					this.processingThreads = 0;
					this.processedThreads = 0;
					this.queueID = 0U;
					this.uniqueID = 0U;
					this.processedEvent = new ManualResetEvent(false);
				}

				// Token: 0x06000224 RID: 548 RVA: 0x00011021 File Offset: 0x0000F221
				public void Unuse()
				{
					this.function = null;
					this.length = 0;
					this.processingThreads = 0;
					this.processedThreads = 0;
					this.queueID += 1U;
				}

				// Token: 0x06000225 RID: 549 RVA: 0x0001104D File Offset: 0x0000F24D
				public void Reuse(PararellFunction function, int length)
				{
					this.function = function;
					this.length = length;
					this.processedEvent.Reset();
				}

				// Token: 0x0400029F RID: 671
				public PararellFunction function;

				// Token: 0x040002A0 RID: 672
				public int length;

				// Token: 0x040002A1 RID: 673
				public int processingThreads;

				// Token: 0x040002A2 RID: 674
				public int processedThreads;

				// Token: 0x040002A3 RID: 675
				public uint queueID;

				// Token: 0x040002A4 RID: 676
				public uint uniqueID;

				// Token: 0x040002A5 RID: 677
				public bool processingWaitEnd;

				// Token: 0x040002A6 RID: 678
				public ManualResetEvent processedEvent;
			}
		}
	}

	// Token: 0x0200004F RID: 79
	public class World
	{
		// Token: 0x06000227 RID: 551 RVA: 0x000110C4 File Offset: 0x0000F2C4
		~World()
		{
			this.Destroy();
		}

		// Token: 0x1700004F RID: 79
		// (get) Token: 0x06000228 RID: 552 RVA: 0x000110F4 File Offset: 0x0000F2F4
		public bool isExpired
		{
			get
			{
				return this.bulletPhysicsWorld == null && this.worldPtr == IntPtr.Zero;
			}
		}

		// Token: 0x06000229 RID: 553 RVA: 0x00011113 File Offset: 0x0000F313
		public bool Create()
		{
			return this.Create(null);
		}

		// Token: 0x0600022A RID: 554 RVA: 0x0001111C File Offset: 0x0000F31C
		public bool Create(WorldProperty worldProperty)
		{
			this.Destroy();
			if (worldProperty != null)
			{
				this.worldProperty = worldProperty;
			}
			else
			{
				this.worldProperty = new WorldProperty();
			}
			this._gravityScaleCached = this.worldProperty.gravityScale;
			this._gravityNoiseCached = this.worldProperty.gravityNoise;
			this._gravityDirectionCached = this.worldProperty.gravityDirection;
			if (!MMD4MecanimBulletPhysics._isUseBulletXNA)
			{
				if (this.worldProperty != null)
				{
					Vector3 gravityDirection = this.worldProperty.gravityDirection;
					gravityDirection.z = -gravityDirection.z;
					MMD4MecanimCommon.PropertyWriter propertyWriter = new MMD4MecanimCommon.PropertyWriter();
					propertyWriter.Write("accurateStep", this.worldProperty.accurateStep);
					propertyWriter.Write("optimizeSettings", this.worldProperty.optimizeSettings);
					propertyWriter.Write("multiThreading", this.worldProperty.multiThreading);
					propertyWriter.Write("parallelDispatcher", this.worldProperty.parallelDispatcher);
					propertyWriter.Write("parallelSolver", this.worldProperty.parallelSolver);
					propertyWriter.Write("framePerSecond", this.worldProperty.framePerSecond);
					propertyWriter.Write("resetFrameRate", this.worldProperty.resetFrameRate);
					propertyWriter.Write("limitDeltaFrames", this.worldProperty.limitDeltaFrames);
					propertyWriter.Write("axisSweepDistance", this.worldProperty.axisSweepDistance);
					propertyWriter.Write("gravityScale", this.worldProperty.gravityScale);
					propertyWriter.Write("gravityNoise", this.worldProperty.gravityNoise);
					propertyWriter.Write("gravityDirection", gravityDirection);
					propertyWriter.Write("vertexScale", this.worldProperty.vertexScale);
					propertyWriter.Write("importScale", this.worldProperty.importScale);
					propertyWriter.Write("worldSolverInfoNumIterations", this.worldProperty.worldSolverInfoNumIterations);
					propertyWriter.Write("worldSolverInfoSplitImpulse", this.worldProperty.worldSolverInfoSplitImpulse);
					propertyWriter.Write("worldAddFloorPlane", this.worldProperty.worldAddFloorPlane);
					propertyWriter.Lock();
					this.worldPtr = MMD4MecanimBulletPhysics._CreateWorld(propertyWriter.iValuesPtr, propertyWriter.iValueLength, propertyWriter.fValuesPtr, propertyWriter.fValueLength);
					propertyWriter.Unlock();
				}
				else
				{
					this.worldPtr = MMD4MecanimBulletPhysics._CreateWorld(IntPtr.Zero, 0, IntPtr.Zero, 0);
				}
				MMD4MecanimBulletPhysics.DebugLog();
				return this.worldPtr != IntPtr.Zero;
			}
			this.bulletPhysicsWorld = new PhysicsWorld();
			if (!this.bulletPhysicsWorld.Create(this.worldProperty))
			{
				this.bulletPhysicsWorld.Destroy();
				this.bulletPhysicsWorld = null;
				return false;
			}
			return true;
		}

		// Token: 0x0600022B RID: 555 RVA: 0x000113B8 File Offset: 0x0000F5B8
		public void SetGravity(float gravityScale, float gravityNoise, Vector3 gravityDirection)
		{
			if (this._gravityScaleCached != gravityScale || this._gravityNoiseCached != gravityNoise || this._gravityDirectionCached != gravityDirection)
			{
				this._gravityScaleCached = gravityScale;
				this._gravityNoiseCached = gravityNoise;
				this._gravityDirectionCached = gravityDirection;
				this._isDirtyProperty = true;
				this.worldProperty.gravityScale = gravityScale;
				this.worldProperty.gravityNoise = gravityNoise;
				this.worldProperty.gravityDirection = gravityDirection;
			}
		}

		// Token: 0x0600022C RID: 556 RVA: 0x00011430 File Offset: 0x0000F630
		public void Destroy()
		{
			if (this.bulletPhysicsWorld != null)
			{
				this.bulletPhysicsWorld.Destroy();
				this.bulletPhysicsWorld = null;
			}
			if (this.worldPtr != IntPtr.Zero)
			{
				IntPtr intPtr = this.worldPtr;
				this.worldPtr = IntPtr.Zero;
				MMD4MecanimBulletPhysics._DestroyWorld(intPtr);
			}
			this.worldProperty = null;
		}

		// Token: 0x0600022D RID: 557 RVA: 0x00011490 File Offset: 0x0000F690
		public void Update(float deltaTime)
		{
			if (this.worldProperty.gravityScale != this._gravityScaleCached || this.worldProperty.gravityNoise != this._gravityNoiseCached || this.worldProperty.gravityDirection != this._gravityDirectionCached)
			{
				this._gravityScaleCached = this.worldProperty.gravityScale;
				this._gravityNoiseCached = this.worldProperty.gravityNoise;
				this._gravityDirectionCached = this.worldProperty.gravityDirection;
				this._isDirtyProperty = true;
			}
			if (this.bulletPhysicsWorld != null)
			{
				if (this._isDirtyProperty)
				{
					this._isDirtyProperty = false;
					this._worldUpdateProperty.gravityScale = this._gravityScaleCached;
					this._worldUpdateProperty.gravityNoise = this._gravityNoiseCached;
					this._worldUpdateProperty.gravityDirection = this._gravityDirectionCached;
					this.bulletPhysicsWorld.Update(deltaTime, this._worldUpdateProperty);
				}
				else
				{
					this.bulletPhysicsWorld.Update(deltaTime, null);
				}
				return;
			}
			if (this.worldPtr != IntPtr.Zero)
			{
				if (this._isDirtyProperty)
				{
					this._isDirtyProperty = false;
					this._updatePropertyWriter.Clear();
					this._updatePropertyWriter.Write("gravityScale", this._gravityScaleCached);
					this._updatePropertyWriter.Write("gravityNoise", this._gravityNoiseCached);
					this._updatePropertyWriter.Write("gravityDirection", this._gravityDirectionCached);
					this._updatePropertyWriter.Lock();
					MMD4MecanimBulletPhysics._UpdateWorld(this.worldPtr, deltaTime, this._updatePropertyWriter.iValuesPtr, this._updatePropertyWriter.iValueLength, this._updatePropertyWriter.fValuesPtr, this._updatePropertyWriter.fValueLength);
					this._updatePropertyWriter.Unlock();
				}
				else
				{
					MMD4MecanimBulletPhysics._UpdateWorld(this.worldPtr, deltaTime, IntPtr.Zero, 0, IntPtr.Zero, 0);
				}
			}
		}

		// Token: 0x040002A7 RID: 679
		public WorldProperty worldProperty;

		// Token: 0x040002A8 RID: 680
		public IntPtr worldPtr;

		// Token: 0x040002A9 RID: 681
		public PhysicsWorld bulletPhysicsWorld;

		// Token: 0x040002AA RID: 682
		private float _gravityScaleCached = 10f;

		// Token: 0x040002AB RID: 683
		private float _gravityNoiseCached;

		// Token: 0x040002AC RID: 684
		private Vector3 _gravityDirectionCached = new Vector3(0f, -1f, 0f);

		// Token: 0x040002AD RID: 685
		private bool _isDirtyProperty = true;

		// Token: 0x040002AE RID: 686
		private MMD4MecanimCommon.PropertyWriter _updatePropertyWriter = new MMD4MecanimCommon.PropertyWriter();

		// Token: 0x040002AF RID: 687
		private WorldUpdateProperty _worldUpdateProperty = new WorldUpdateProperty();
	}

	// Token: 0x02000050 RID: 80
	public class RigidBody
	{
		// Token: 0x17000050 RID: 80
		// (get) Token: 0x0600022F RID: 559 RVA: 0x00011690 File Offset: 0x0000F890
		private Vector3 _center
		{
			get
			{
				if (this._sphereCollider != null)
				{
					return this._sphereCollider.center;
				}
				if (this._boxCollider != null)
				{
					return this._boxCollider.center;
				}
				if (this._capsuleCollider != null)
				{
					return this._capsuleCollider.center;
				}
				return Vector3.zero;
			}
		}

		// Token: 0x06000230 RID: 560 RVA: 0x000116FC File Offset: 0x0000F8FC
		~RigidBody()
		{
			this.Destroy();
		}

		// Token: 0x17000051 RID: 81
		// (get) Token: 0x06000231 RID: 561 RVA: 0x0001172C File Offset: 0x0000F92C
		public bool isExpired
		{
			get
			{
				return this.bulletRigidBody == null && this.rigidBodyPtr == IntPtr.Zero;
			}
		}

		// Token: 0x06000232 RID: 562 RVA: 0x0001174C File Offset: 0x0000F94C
		public bool Create(MMD4MecanimRigidBody rigidBody)
		{
			this.Destroy();
			if (rigidBody == null)
			{
				return false;
			}
			MMD4MecanimBulletPhysics.World world = null;
			if (MMD4MecanimBulletPhysics.instance != null)
			{
				world = MMD4MecanimBulletPhysics.instance.globalWorld;
			}
			if (world == null)
			{
				return false;
			}
			MMD4MecanimInternal.Bullet.RigidBody.CreateProperty createProperty = default(MMD4MecanimInternal.Bullet.RigidBody.CreateProperty);
			bool isUseBulletXNA = MMD4MecanimBulletPhysics._isUseBulletXNA;
			MMD4MecanimCommon.PropertyWriter propertyWriter = (!isUseBulletXNA) ? new MMD4MecanimCommon.PropertyWriter() : null;
			Matrix4x4 localToWorldMatrix = rigidBody.transform.localToWorldMatrix;
			Vector3 vector = rigidBody.transform.position;
			Quaternion quaternion = rigidBody.transform.rotation;
			Vector3 vector2 = MMD4MecanimCommon.ComputeMatrixScale(ref localToWorldMatrix);
			Vector3 center = this._center;
			if (center != Vector3.zero)
			{
				vector = localToWorldMatrix.MultiplyPoint3x4(center);
			}
			SphereCollider component = rigidBody.gameObject.GetComponent<SphereCollider>();
			if (component != null)
			{
				float num = component.radius;
				num *= Mathf.Max(Mathf.Max(vector2.x, vector2.y), vector2.z);
				if (propertyWriter != null)
				{
					propertyWriter.Write("shapeType", 0);
					propertyWriter.Write("shapeSize", new Vector3(num, 0f, 0f));
				}
				if (isUseBulletXNA)
				{
					createProperty.shapeType = 0;
					createProperty.shapeSize = new Vector3(num, 0f, 0f);
				}
			}
			BoxCollider component2 = rigidBody.gameObject.GetComponent<BoxCollider>();
			if (component2 != null)
			{
				Vector3 size = component2.size;
				size.x *= vector2.x;
				size.y *= vector2.y;
				size.z *= vector2.z;
				if (propertyWriter != null)
				{
					propertyWriter.Write("shapeType", 1);
					propertyWriter.Write("shapeSize", size * 0.5f);
				}
				if (isUseBulletXNA)
				{
					createProperty.shapeType = 1;
					createProperty.shapeSize = size * 0.5f;
				}
			}
			CapsuleCollider component3 = rigidBody.gameObject.GetComponent<CapsuleCollider>();
			if (component3 != null)
			{
				Vector3 vector3 = new Vector3(component3.radius, component3.height, 0f);
				vector3.x *= Mathf.Max(vector2.x, vector2.z);
				vector3.y *= vector2.y;
				vector3.y -= component3.radius * 2f;
				if (propertyWriter != null)
				{
					propertyWriter.Write("shapeType", 2);
					propertyWriter.Write("shapeSize", vector3);
				}
				if (isUseBulletXNA)
				{
					createProperty.shapeType = 2;
					createProperty.shapeSize = vector3;
				}
			}
			this._sphereCollider = component;
			this._boxCollider = component2;
			this._capsuleCollider = component3;
			if (component3 != null)
			{
				if (component3.direction == 0)
				{
					quaternion *= MMD4MecanimBulletPhysics.rotateQuaternionX;
				}
				else if (component3.direction == 2)
				{
					quaternion *= MMD4MecanimBulletPhysics.rotateQuaternionZ;
				}
			}
			if (world.worldProperty != null)
			{
				if (propertyWriter != null)
				{
					propertyWriter.Write("worldScale", world.worldProperty.worldScale);
				}
				if (isUseBulletXNA)
				{
					createProperty.unityScale = world.worldProperty.worldScale;
				}
			}
			else
			{
				if (propertyWriter != null)
				{
					propertyWriter.Write("worldScale", 1f);
				}
				if (isUseBulletXNA)
				{
					createProperty.unityScale = 1f;
				}
			}
			if (propertyWriter != null)
			{
				propertyWriter.Write("position", vector);
				propertyWriter.Write("rotation", quaternion);
			}
			if (isUseBulletXNA)
			{
				createProperty.position = vector;
				createProperty.rotation = quaternion;
			}
			int num2 = 0;
			if (rigidBody.bulletPhysicsRigidBodyProperty != null)
			{
				if (rigidBody.bulletPhysicsRigidBodyProperty.isKinematic)
				{
					num2 |= 1;
				}
				if (rigidBody.bulletPhysicsRigidBodyProperty.isAdditionalDamping)
				{
					num2 |= 2;
				}
				if (isUseBulletXNA)
				{
					createProperty.isKinematic = rigidBody.bulletPhysicsRigidBodyProperty.isKinematic;
					createProperty.isAdditionalDamping = rigidBody.bulletPhysicsRigidBodyProperty.isAdditionalDamping;
				}
				float num3 = rigidBody.bulletPhysicsRigidBodyProperty.mass;
				if (rigidBody.bulletPhysicsRigidBodyProperty.isKinematic)
				{
					num3 = 0f;
				}
				if (propertyWriter != null)
				{
					propertyWriter.Write("mass", num3);
					propertyWriter.Write("linearDamping", rigidBody.bulletPhysicsRigidBodyProperty.linearDamping);
					propertyWriter.Write("angularDamping", rigidBody.bulletPhysicsRigidBodyProperty.angularDamping);
					propertyWriter.Write("restitution", rigidBody.bulletPhysicsRigidBodyProperty.restitution);
					propertyWriter.Write("friction", rigidBody.bulletPhysicsRigidBodyProperty.friction);
				}
				if (isUseBulletXNA)
				{
					createProperty.mass = num3;
					createProperty.linearDamping = rigidBody.bulletPhysicsRigidBodyProperty.linearDamping;
					createProperty.angularDamping = rigidBody.bulletPhysicsRigidBodyProperty.angularDamping;
					createProperty.restitution = rigidBody.bulletPhysicsRigidBodyProperty.restitution;
					createProperty.friction = rigidBody.bulletPhysicsRigidBodyProperty.friction;
				}
			}
			if (propertyWriter != null)
			{
				propertyWriter.Write("flags", num2);
				propertyWriter.Write("group", 65535);
				propertyWriter.Write("mask", 65535);
			}
			if (isUseBulletXNA)
			{
				createProperty.group = 65535;
				createProperty.mask = 65535;
			}
			if (isUseBulletXNA)
			{
				this.bulletRigidBody = new MMD4MecanimInternal.Bullet.RigidBody();
				if (!this.bulletRigidBody.Create(ref createProperty))
				{
					this.bulletRigidBody.Destroy();
					this.bulletRigidBody = null;
					return false;
				}
				if (world.bulletPhysicsWorld != null)
				{
					world.bulletPhysicsWorld.JoinWorld(this.bulletRigidBody);
				}
				this.rigidBody = rigidBody;
				return true;
			}
			else
			{
				propertyWriter.Lock();
				IntPtr value = MMD4MecanimBulletPhysics._CreateRigidBody(propertyWriter.iValuesPtr, propertyWriter.iValueLength, propertyWriter.fValuesPtr, propertyWriter.fValueLength);
				propertyWriter.Unlock();
				if (value != IntPtr.Zero)
				{
					MMD4MecanimBulletPhysics._JoinWorldRigidBody(world.worldPtr, value);
					MMD4MecanimBulletPhysics.DebugLog();
					this.rigidBody = rigidBody;
					this.rigidBodyPtr = value;
					return true;
				}
				MMD4MecanimBulletPhysics.DebugLog();
				return false;
			}
		}

		// Token: 0x06000233 RID: 563 RVA: 0x00011D68 File Offset: 0x0000FF68
		public void Update()
		{
			if (this.rigidBody != null && this.rigidBody.bulletPhysicsRigidBodyProperty != null)
			{
				bool isKinematic = this.rigidBody.bulletPhysicsRigidBodyProperty.isKinematic;
				bool isFreezed = this.rigidBody.bulletPhysicsRigidBodyProperty.isFreezed;
				if (isKinematic || isFreezed)
				{
					int num = 0;
					if (isFreezed)
					{
						num |= 1;
					}
					Vector3 vector = this.rigidBody.transform.position;
					Quaternion lhs = this.rigidBody.transform.rotation;
					Vector3 center = this._center;
					if (center != Vector3.zero)
					{
						vector = this.rigidBody.transform.localToWorldMatrix.MultiplyPoint3x4(center);
					}
					if (this._capsuleCollider != null)
					{
						if (this._capsuleCollider.direction == 0)
						{
							lhs *= MMD4MecanimBulletPhysics.rotateQuaternionX;
						}
						else if (this._capsuleCollider.direction == 2)
						{
							lhs *= MMD4MecanimBulletPhysics.rotateQuaternionZ;
						}
					}
					if (this.bulletRigidBody != null)
					{
						this.bulletRigidBody.Update(num, ref vector, ref lhs);
					}
					if (this.rigidBodyPtr != IntPtr.Zero)
					{
						this.fValues[0] = vector.x;
						this.fValues[1] = vector.y;
						this.fValues[2] = vector.z;
						this.fValues[3] = lhs.x;
						this.fValues[4] = lhs.y;
						this.fValues[5] = lhs.z;
						this.fValues[6] = lhs.w;
						GCHandle gchandle = GCHandle.Alloc(this.fValues, GCHandleType.Pinned);
						MMD4MecanimBulletPhysics._UpdateRigidBody(this.rigidBodyPtr, num, IntPtr.Zero, 0, gchandle.AddrOfPinnedObject(), this.fValues.Length);
						gchandle.Free();
					}
				}
				else
				{
					if (this.bulletRigidBody != null)
					{
						this.bulletRigidBody.Update(0);
					}
					if (this.rigidBodyPtr != IntPtr.Zero)
					{
						GCHandle gchandle2 = GCHandle.Alloc(this.fValues, GCHandleType.Pinned);
						MMD4MecanimBulletPhysics._UpdateRigidBody(this.rigidBodyPtr, 0, IntPtr.Zero, 0, IntPtr.Zero, 0);
						gchandle2.Free();
					}
				}
			}
		}

		// Token: 0x06000234 RID: 564 RVA: 0x00011FA8 File Offset: 0x000101A8
		public void LateUpdate()
		{
			if (this.ignoreBulletPhysics)
			{
				return;
			}
			if (this.rigidBody != null && this.rigidBody.bulletPhysicsRigidBodyProperty != null)
			{
				bool isKinematic = this.rigidBody.bulletPhysicsRigidBodyProperty.isKinematic;
				bool isFreezed = this.rigidBody.bulletPhysicsRigidBodyProperty.isFreezed;
				if (!isKinematic && !isFreezed)
				{
					Vector3 one = Vector3.one;
					Quaternion quaternion = Quaternion.identity;
					int num = 0;
					if (this.bulletRigidBody != null)
					{
						num = this.bulletRigidBody.LateUpdate(ref one, ref quaternion);
					}
					if (this.rigidBodyPtr != IntPtr.Zero)
					{
						GCHandle gchandle = GCHandle.Alloc(this.fValues, GCHandleType.Pinned);
						num = MMD4MecanimBulletPhysics._LateUpdateRigidBody(this.rigidBodyPtr, IntPtr.Zero, 0, gchandle.AddrOfPinnedObject(), this.fValues.Length);
						gchandle.Free();
						one = new Vector3(this.fValues[0], this.fValues[1], this.fValues[2]);
						quaternion = new Quaternion(this.fValues[3], this.fValues[4], this.fValues[5], this.fValues[6]);
					}
					if (num != 0)
					{
						if (this._capsuleCollider != null)
						{
							if (this._capsuleCollider.direction == 0)
							{
								quaternion *= MMD4MecanimBulletPhysics.rotateQuaternionXInv;
							}
							else if (this._capsuleCollider.direction == 2)
							{
								quaternion *= MMD4MecanimBulletPhysics.rotateQuaternionZInv;
							}
						}
						this.rigidBody.gameObject.transform.position = one;
						this.rigidBody.gameObject.transform.rotation = quaternion;
						Vector3 center = this._center;
						if (center != Vector3.zero)
						{
							Vector3 vector = this.rigidBody.gameObject.transform.localPosition;
							vector -= center;
							this.rigidBody.gameObject.transform.localPosition = vector;
						}
					}
				}
			}
		}

		// Token: 0x06000235 RID: 565 RVA: 0x000121A4 File Offset: 0x000103A4
		public void Destroy()
		{
			if (this.bulletRigidBody != null)
			{
				this.bulletRigidBody.Destroy();
				this.bulletRigidBody = null;
			}
			if (this.rigidBodyPtr != IntPtr.Zero)
			{
				IntPtr intPtr = this.rigidBodyPtr;
				this.rigidBodyPtr = IntPtr.Zero;
				MMD4MecanimBulletPhysics._DestroyRigidBody(intPtr);
			}
			this._sphereCollider = null;
			this._boxCollider = null;
			this._capsuleCollider = null;
			this.rigidBody = null;
		}

		// Token: 0x040002B0 RID: 688
		public MMD4MecanimRigidBody rigidBody;

		// Token: 0x040002B1 RID: 689
		public IntPtr rigidBodyPtr;

		// Token: 0x040002B2 RID: 690
		public MMD4MecanimInternal.Bullet.RigidBody bulletRigidBody;

		// Token: 0x040002B3 RID: 691
		private float[] fValues = new float[7];

		// Token: 0x040002B4 RID: 692
		private SphereCollider _sphereCollider;

		// Token: 0x040002B5 RID: 693
		private BoxCollider _boxCollider;

		// Token: 0x040002B6 RID: 694
		private CapsuleCollider _capsuleCollider;

		// Token: 0x040002B7 RID: 695
		private bool ignoreBulletPhysics = true;

		// Token: 0x02000051 RID: 81
		[Flags]
		public enum UpdateFlags
		{
			// Token: 0x040002B9 RID: 697
			Freezed = 1
		}
	}

	// Token: 0x02000052 RID: 82
	public class MMDModel
	{
		// Token: 0x17000052 RID: 82
		// (get) Token: 0x06000237 RID: 567 RVA: 0x00012231 File Offset: 0x00010431
		public int[] fullBodyIKBoneIDList
		{
			get
			{
				return this._fullBodyIKBoneIDList;
			}
		}

		// Token: 0x17000053 RID: 83
		// (get) Token: 0x06000238 RID: 568 RVA: 0x00012239 File Offset: 0x00010439
		public Vector3[] fullBodyIKPositionList
		{
			get
			{
				return this._fullBodyIKPositionList;
			}
		}

		// Token: 0x17000054 RID: 84
		// (get) Token: 0x06000239 RID: 569 RVA: 0x00012241 File Offset: 0x00010441
		public Quaternion[] fullBodyIKRotationList
		{
			get
			{
				return this._fullBodyIKRotationList;
			}
		}

		// Token: 0x17000055 RID: 85
		// (get) Token: 0x0600023A RID: 570 RVA: 0x00012249 File Offset: 0x00010449
		public int[] updateFullBodyIKFlagsList
		{
			get
			{
				return this._updateFullBodyIKFlagsList;
			}
		}

		// Token: 0x17000056 RID: 86
		// (get) Token: 0x0600023B RID: 571 RVA: 0x00012251 File Offset: 0x00010451
		public float[] updateFullBodyIKTransformList
		{
			get
			{
				return this._updateFullBodyIKTransformList;
			}
		}

		// Token: 0x17000057 RID: 87
		// (get) Token: 0x0600023C RID: 572 RVA: 0x00012259 File Offset: 0x00010459
		public float[] updateFullBodyIKWeightList
		{
			get
			{
				return this._updateFullBodyIKWeightList;
			}
		}

		// Token: 0x0600023D RID: 573 RVA: 0x00012264 File Offset: 0x00010464
		~MMDModel()
		{
			this.Destroy();
		}

		// Token: 0x17000058 RID: 88
		// (get) Token: 0x0600023E RID: 574 RVA: 0x00012294 File Offset: 0x00010494
		public bool isExpired
		{
			get
			{
				return this.bulletMMDModel == null && this.mmdModelPtr == IntPtr.Zero && this.localWorld == null;
			}
		}

		// Token: 0x0600023F RID: 575 RVA: 0x000122C4 File Offset: 0x000104C4
		private bool _Prepare(MMD4MecanimModel model)
		{
			if (model == null)
			{
				return false;
			}
			this.model = model;
			this._modelTransform = model.transform;
			MMD4MecanimData.ModelData modelData = model.modelData;
			if (modelData == null || modelData.boneDataList == null || model.boneList == null || model.boneList.Length != modelData.boneDataList.Length)
			{
				UnityEngine.Debug.LogError("_Prepare: Failed.");
				return false;
			}
			if (modelData.boneDataList != null)
			{
				int num = modelData.boneDataList.Length;
				this._boneTransformList = new Transform[num];
				for (int i = 0; i < num; i++)
				{
					if (model.boneList[i] != null && model.boneList[i].gameObject != null)
					{
						this._boneTransformList[i] = model.boneList[i].gameObject.transform;
					}
				}
			}
			else
			{
				this._boneTransformList = new Transform[0];
			}
			if (modelData.ikDataList != null)
			{
				int num2 = modelData.ikDataList.Length;
				this._ikWeightList = new float[num2];
				this._ikDisabledList = new bool[num2];
				this._updateIKWeightList = new float[num2];
				for (int j = 0; j < num2; j++)
				{
					this._ikWeightList[j] = 1f;
					this._updateIKWeightList[j] = 1f;
				}
			}
			else
			{
				this._ikWeightList = new float[0];
				this._ikDisabledList = new bool[0];
				this._updateIKWeightList = new float[0];
			}
			if (modelData.morphDataList != null)
			{
				int num3 = modelData.morphDataList.Length;
				this._updateMorphWeightList = new float[num3];
			}
			else
			{
				this._updateMorphWeightList = new float[0];
			}
			if (modelData.rigidBodyDataList != null)
			{
				int num4 = modelData.rigidBodyDataList.Length;
				this._updateRigidBodyFlagsList = new int[num4];
				for (int k = 0; k < num4; k++)
				{
					MMD4MecanimData.RigidBodyData rigidBodyData = modelData.rigidBodyDataList[k];
					if (rigidBodyData.isFreezed)
					{
						this._updateRigidBodyFlagsList[k] |= 1;
					}
				}
			}
			else
			{
				this._updateRigidBodyFlagsList = new int[0];
			}
			this._physicsEnabled = (model.physicsEngine != MMD4MecanimModel.PhysicsEngine.None);
			this._isDirtyPreUpdate = true;
			this._PrepareWork(model);
			return true;
		}

		// Token: 0x06000240 RID: 576 RVA: 0x00012518 File Offset: 0x00010718
		public bool Create(MMD4MecanimModel model)
		{
			if (model == null)
			{
				return false;
			}
			byte[] modelFileBytes = model.modelFileBytes;
			if (modelFileBytes == null)
			{
				UnityEngine.Debug.LogError(string.Empty);
				return false;
			}
			if (!this._Prepare(model))
			{
				UnityEngine.Debug.LogError(string.Empty);
				return false;
			}
			if (this._modelTransform != null)
			{
				this._lossyScale = this._modelTransform.transform.lossyScale;
			}
			else
			{
				this._lossyScale = Vector3.one;
			}
			bool flag = true;
			bool flag2 = true;
			bool flag3 = false;
			float num = 0f;
			float num2 = 0f;
			MMDModelProperty mmdmodelProperty = null;
			WorldProperty worldProperty = null;
			if (model.bulletPhysics != null)
			{
				mmdmodelProperty = model.bulletPhysics.mmdModelProperty;
				worldProperty = model.bulletPhysics.worldProperty;
				flag = model.bulletPhysics.joinLocalWorld;
				flag2 = model.bulletPhysics.useOriginalScale;
				flag3 = model.bulletPhysics.useCustomResetTime;
				num = model.bulletPhysics.resetMorphTime;
				num2 = model.bulletPhysics.resetWaitTime;
			}
			float importScale = model.importScale;
			MMD4MecanimBulletPhysics.World world = null;
			MMD4MecanimBulletPhysics.World world2 = null;
			if (importScale == 0f)
			{
				importScale = model.modelData.importScale;
			}
			float num3;
			bool optimizeSettings;
			if (flag)
			{
				if (worldProperty == null)
				{
					UnityEngine.Debug.LogError("localWorldProperty is null.");
					return false;
				}
				world2 = new MMD4MecanimBulletPhysics.World();
				world = world2;
				if (!world2.Create(worldProperty))
				{
					UnityEngine.Debug.LogError(string.Empty);
					return false;
				}
				if (flag2)
				{
					num3 = model.modelData.vertexScale * importScale;
				}
				else
				{
					num3 = worldProperty.worldScale;
				}
				optimizeSettings = worldProperty.optimizeSettings;
			}
			else
			{
				if (MMD4MecanimBulletPhysics.instance != null)
				{
					world = MMD4MecanimBulletPhysics.instance.globalWorld;
				}
				if (world == null)
				{
					UnityEngine.Debug.LogError(string.Empty);
					return false;
				}
				if (world.worldProperty == null)
				{
					UnityEngine.Debug.LogError("worldProperty is null.");
					return false;
				}
				num3 = world.worldProperty.worldScale;
				optimizeSettings = world.worldProperty.optimizeSettings;
			}
			bool xdefEnabled = model.xdefEnabled;
			bool vertexMorphEnabled = model.vertexMorphEnabled;
			bool flag4 = model.blendShapesEnabled;
			byte[] array = null;
			byte[] array2 = null;
			int[] array3 = null;
			if (model.skinningEnabled)
			{
				if (vertexMorphEnabled || xdefEnabled)
				{
					bool flag5 = false;
					array3 = model._PrepareMeshFlags(out flag5);
					flag4 = (vertexMorphEnabled && flag4 && flag5);
					if ((vertexMorphEnabled && !flag4) || xdefEnabled)
					{
						array = model.indexFileBytes;
						if (array != null)
						{
							array2 = model.vertexFileBytes;
						}
					}
				}
				else
				{
					array3 = model._PrepareMeshFlags();
				}
			}
			bool isUseBulletXNA = MMD4MecanimBulletPhysics._isUseBulletXNA;
			if (isUseBulletXNA)
			{
				MMD4MecanimInternal.Bullet.MMDModel.ImportProperty importProperty = default(MMD4MecanimInternal.Bullet.MMDModel.ImportProperty);
				importProperty.isPhysicsEnabled = this._physicsEnabled;
				importProperty.isJoinedLocalWorld = flag;
				importProperty.isVertexMorphEnabled = vertexMorphEnabled;
				importProperty.isBlendShapesEnabled = flag4;
				importProperty.isXDEFEnabled = xdefEnabled;
				importProperty.isXDEFNormalEnabled = model.xdefNormalEnabled;
				importProperty.useCustomResetTime = flag3;
				importProperty.resetMorphTime = num;
				importProperty.resetWaitTime = num2;
				importProperty.mmdModelProperty = mmdmodelProperty;
				importProperty.optimizeSettings = optimizeSettings;
				if (importProperty.mmdModelProperty != null)
				{
					importProperty.mmdModelProperty.worldScale = num3;
					importProperty.mmdModelProperty.importScale = importScale;
					importProperty.mmdModelProperty.lossyScale = this._lossyScale;
				}
				this.bulletMMDModel = new MMD4MecanimInternal.Bullet.MMDModel();
				if (!this.bulletMMDModel.Import(modelFileBytes, array, array2, array3, ref importProperty))
				{
					UnityEngine.Debug.LogError(string.Empty);
					this.bulletMMDModel.Destroy();
					if (world2 != null)
					{
						world2.Destroy();
					}
					return false;
				}
				if (world != null && world.bulletPhysicsWorld != null)
				{
					world.bulletPhysicsWorld.JoinWorld(this.bulletMMDModel);
				}
				this.localWorld = world2;
				this._UploadMesh(model, array3);
				return true;
			}
			else
			{
				MMD4MecanimCommon.PropertyWriter propertyWriter = new MMD4MecanimCommon.PropertyWriter();
				propertyWriter.Write("worldScale", num3);
				propertyWriter.Write("importScale", importScale);
				propertyWriter.Write("lossyScale", this._lossyScale);
				propertyWriter.Write("optimizeSettings", optimizeSettings);
				if (flag3)
				{
					propertyWriter.Write("resetMorphTime", num);
					propertyWriter.Write("resetWaitTime", num2);
				}
				if (mmdmodelProperty != null)
				{
					propertyWriter.Write("isPhysicsEnabled", this._physicsEnabled);
					propertyWriter.Write("isJoinedLocalWorld", flag);
					propertyWriter.Write("isVertexMorphEnabled", vertexMorphEnabled);
					propertyWriter.Write("isBlendShapesEnabled", flag4);
					propertyWriter.Write("isXDEFEnabled", xdefEnabled);
					propertyWriter.Write("isXDEFNormalEnabled", model.xdefNormalEnabled);
					propertyWriter.Write("rigidBodyIsAdditionalDamping", mmdmodelProperty.rigidBodyIsAdditionalDamping);
					propertyWriter.Write("rigidBodyIsEnableSleeping", mmdmodelProperty.rigidBodyIsEnableSleeping);
					propertyWriter.Write("rigidBodyIsUseCcd", mmdmodelProperty.rigidBodyIsUseCcd);
					propertyWriter.Write("rigidBodyCcdMotionThreshold", mmdmodelProperty.rigidBodyCcdMotionThreshold);
					propertyWriter.Write("rigidBodyShapeScale", mmdmodelProperty.rigidBodyShapeScale);
					propertyWriter.Write("rigidBodyMassRate", mmdmodelProperty.rigidBodyMassRate);
					propertyWriter.Write("rigidBodyLinearDampingRate", mmdmodelProperty.rigidBodyLinearDampingRate);
					propertyWriter.Write("rigidBodyAngularDampingRate", mmdmodelProperty.rigidBodyAngularDampingRate);
					propertyWriter.Write("rigidBodyRestitutionRate", mmdmodelProperty.rigidBodyRestitutionRate);
					propertyWriter.Write("rigidBodyFrictionRate", mmdmodelProperty.rigidBodyFrictionRate);
					propertyWriter.Write("rigidBodyAntiJitterRate", mmdmodelProperty.rigidBodyAntiJitterRate);
					propertyWriter.Write("rigidBodyAntiJitterRateOnKinematic", mmdmodelProperty.rigidBodyAntiJitterRateOnKinematic);
					propertyWriter.Write("rigidBodyPreBoneAlignmentLimitLength", mmdmodelProperty.rigidBodyPreBoneAlignmentLimitLength);
					propertyWriter.Write("rigidBodyPreBoneAlignmentLossRate", mmdmodelProperty.rigidBodyPreBoneAlignmentLossRate);
					propertyWriter.Write("rigidBodyPostBoneAlignmentLimitLength", mmdmodelProperty.rigidBodyPostBoneAlignmentLimitLength);
					propertyWriter.Write("rigidBodyPostBoneAlignmentLossRate", mmdmodelProperty.rigidBodyPostBoneAlignmentLossRate);
					propertyWriter.Write("rigidBodyLinearDampingLossRate", mmdmodelProperty.rigidBodyLinearDampingLossRate);
					propertyWriter.Write("rigidBodyAngularDampingLossRate", mmdmodelProperty.rigidBodyAngularDampingLossRate);
					propertyWriter.Write("rigidBodyLinearVelocityLimit", mmdmodelProperty.rigidBodyLinearVelocityLimit);
					propertyWriter.Write("rigidBodyAngularVelocityLimit", mmdmodelProperty.rigidBodyAngularVelocityLimit);
					propertyWriter.Write("rigidBodyIsUseForceAngularVelocityLimit", mmdmodelProperty.rigidBodyIsUseForceAngularVelocityLimit);
					propertyWriter.Write("rigidBodyIsUseForceAngularAccelerationLimit", mmdmodelProperty.rigidBodyIsUseForceAngularAccelerationLimit);
					propertyWriter.Write("rigidBodyForceAngularVelocityLimit", mmdmodelProperty.rigidBodyForceAngularVelocityLimit);
					propertyWriter.Write("rigidBodyIsAdditionalCollider", mmdmodelProperty.rigidBodyIsAdditionalCollider);
					propertyWriter.Write("rigidBodyAdditionalColliderBias", mmdmodelProperty.rigidBodyAdditionalColliderBias);
					propertyWriter.Write("rigidBodyIsForceTranslate", mmdmodelProperty.rigidBodyIsForceTranslate);
					propertyWriter.Write("jointRootAdditionalLimitAngle", mmdmodelProperty.jointRootAdditionalLimitAngle);
				}
				MMD4MecanimCommon.GCHValues<byte> v = MMD4MecanimCommon.MakeGCHValues<byte>(modelFileBytes);
				MMD4MecanimCommon.GCHValues<byte> v2 = MMD4MecanimCommon.MakeGCHValues<byte>(array);
				MMD4MecanimCommon.GCHValues<byte> v3 = MMD4MecanimCommon.MakeGCHValues<byte>(array2);
				MMD4MecanimCommon.GCHValues<int> v4 = MMD4MecanimCommon.MakeGCHValues<int>(array3);
				propertyWriter.Lock();
				IntPtr value = MMD4MecanimBulletPhysics._CreateMMDModel(v, v.length, v2, v2.length, v3, v3.length, v4, v4.length, propertyWriter.iValuesPtr, propertyWriter.iValueLength, propertyWriter.fValuesPtr, propertyWriter.fValueLength);
				propertyWriter.Unlock();
				v4.Free();
				v3.Free();
				v2.Free();
				v.Free();
				if (value != IntPtr.Zero)
				{
					MMD4MecanimBulletPhysics._JoinWorldMMDModel(world.worldPtr, value);
					MMD4MecanimBulletPhysics.DebugLog();
					this.localWorld = world2;
					this.mmdModelPtr = value;
					this._UploadMesh(model, array3);
					return true;
				}
				if (world2 != null)
				{
					world2.Destroy();
				}
				MMD4MecanimBulletPhysics.DebugLog();
				UnityEngine.Debug.LogError(string.Empty);
				return false;
			}
		}

		// Token: 0x06000241 RID: 577 RVA: 0x00012CB8 File Offset: 0x00010EB8
		private void _UploadMesh(MMD4MecanimModel model, int[] meshFlags)
		{
			if (model == null || meshFlags == null || meshFlags.Length == 0)
			{
				return;
			}
			model._InitializeCloneMesh(meshFlags);
			if (this.bulletMMDModel != null)
			{
				for (int num = 0; num != meshFlags.Length; num++)
				{
					if ((meshFlags[num] & 6) != 0)
					{
						MMD4MecanimModel.CloneMesh cloneMesh = model._GetCloneMesh(num);
						if (cloneMesh != null)
						{
							Vector3[] vertices = cloneMesh.vertices;
							Vector3[] normals = null;
							BoneWeight[] boneWeights = null;
							Matrix4x4[] bindposes = null;
							if ((meshFlags[num] & 4) != 0)
							{
								if (model.xdefNormalEnabled)
								{
									normals = cloneMesh.normals;
								}
								boneWeights = cloneMesh.boneWeights;
								bindposes = cloneMesh.bindposes;
							}
							this.bulletMMDModel.UploadMesh(num, vertices, normals, boneWeights, bindposes);
						}
					}
				}
			}
			if (this.mmdModelPtr != IntPtr.Zero)
			{
				for (int num2 = 0; num2 != meshFlags.Length; num2++)
				{
					if ((meshFlags[num2] & 6) != 0)
					{
						MMD4MecanimModel.CloneMesh cloneMesh2 = model._GetCloneMesh(num2);
						if (cloneMesh2 != null)
						{
							Vector3[] vertices2 = cloneMesh2.vertices;
							Vector3[] values = null;
							BoneWeight[] values2 = null;
							Matrix4x4[] values3 = null;
							if ((meshFlags[num2] & 4) != 0)
							{
								if (model.xdefNormalEnabled)
								{
									values = cloneMesh2.normals;
								}
								values2 = cloneMesh2.boneWeights;
								values3 = cloneMesh2.bindposes;
							}
							MMD4MecanimCommon.GCHValues<Vector3> v = MMD4MecanimCommon.MakeGCHValues<Vector3>(vertices2);
							MMD4MecanimCommon.GCHValues<Vector3> v2 = MMD4MecanimCommon.MakeGCHValues<Vector3>(values);
							MMD4MecanimCommon.GCHValues<BoneWeight> v3 = MMD4MecanimCommon.MakeGCHValues<BoneWeight>(values2);
							MMD4MecanimCommon.GCHValues<Matrix4x4> v4 = MMD4MecanimCommon.MakeGCHValues<Matrix4x4>(values3);
							MMD4MecanimBulletPhysics._UploadMeshMMDModel(this.mmdModelPtr, num2, v, v2, v3, v.length, v4, v4.length);
							v3.Free();
							v2.Free();
							v.Free();
						}
					}
				}
				MMD4MecanimBulletPhysics.DebugLog();
			}
			model._CleanupCloneMesh();
		}

		// Token: 0x06000242 RID: 578 RVA: 0x00012E74 File Offset: 0x00011074
		private void _PrepareWork(MMD4MecanimModel model)
		{
			int num = 0;
			if (this._boneTransformList != null)
			{
				num = this._boneTransformList.Length;
			}
			this._fullBodyIKBoneIDList = new int[36];
			this._fullBodyIKPositionList = new Vector3[36];
			this._fullBodyIKRotationList = new Quaternion[36];
			for (int num2 = 0; num2 != 36; num2++)
			{
				this._fullBodyIKBoneIDList[num2] = -1;
				this._fullBodyIKPositionList[num2] = Vector3.zero;
				this._fullBodyIKRotationList[num2] = Quaternion.identity;
			}
			this._updateIValues = new int[1];
			this._updateFValues = new float[2];
			this._updateBoneFlagsList = new int[num];
			this._updateBoneTransformList = new Matrix4x4[num];
			this._updateBonePositionList = new Vector3[num];
			this._updateBoneRotationList = new Quaternion[num];
			this._updateUserPositionList = new Vector3[num];
			this._updateUserRotationList = new Quaternion[num];
			this._updateUserPositionIsValidList = new uint[(num + 31) / 32];
			this._updateUserRotationIsValidList = new uint[(num + 31) / 32];
			for (int num3 = 0; num3 != num; num3++)
			{
				this._updateUserPositionList[num3] = Vector3.zero;
				this._updateUserRotationList[num3] = Quaternion.identity;
			}
			this._updateFullBodyIKFlagsList = new int[36];
			this._updateFullBodyIKTransformList = new float[144];
			this._updateFullBodyIKWeightList = new float[36];
			for (int num4 = 0; num4 != 36; num4++)
			{
				this._updateFullBodyIKWeightList[num4] = 1f;
			}
		}

		// Token: 0x06000243 RID: 579 RVA: 0x00013014 File Offset: 0x00011214
		public void Destroy()
		{
			if (this.bulletMMDModel != null)
			{
				this.bulletMMDModel.Destroy();
				this.bulletMMDModel = null;
			}
			if (this.mmdModelPtr != IntPtr.Zero)
			{
				IntPtr intPtr = this.mmdModelPtr;
				this.mmdModelPtr = IntPtr.Zero;
				MMD4MecanimBulletPhysics._DestroyMMDModel(intPtr);
			}
			if (this.localWorld != null)
			{
				this.localWorld.Destroy();
				this.localWorld = null;
			}
			this._modelTransform = null;
			this.model = null;
		}

		// Token: 0x06000244 RID: 580 RVA: 0x00013098 File Offset: 0x00011298
		public void SetRigidBodyFreezed(int rigidBodyID, bool isFreezed)
		{
			if (this._updateRigidBodyFlagsList != null && rigidBodyID < this._updateRigidBodyFlagsList.Length)
			{
				int num = this._updateRigidBodyFlagsList[rigidBodyID];
				bool flag = (num & 1) != 0;
				if (isFreezed != flag)
				{
					this._isDirtyPreUpdate = true;
					if (isFreezed)
					{
						num |= 1;
					}
					else
					{
						num &= -2;
					}
					this._updateRigidBodyFlagsList[rigidBodyID] = num;
				}
			}
		}

		// Token: 0x06000245 RID: 581 RVA: 0x000130FC File Offset: 0x000112FC
		public void SetIKProperty(int ikID, bool isEnabled, float ikWeight)
		{
			if (this._ikWeightList != null && this._ikDisabledList != null && this._updateIKWeightList != null && ikID < this._ikWeightList.Length && (this._ikDisabledList[ikID] != !isEnabled || this._ikWeightList[ikID] != ikWeight))
			{
				this._isDirtyPreUpdate = true;
				this._ikDisabledList[ikID] = !isEnabled;
				this._ikWeightList[ikID] = ikWeight;
				if (isEnabled)
				{
					this._updateIKWeightList[ikID] = ikWeight;
				}
				else
				{
					this._updateIKWeightList[ikID] = 0f;
				}
			}
		}

		// Token: 0x06000246 RID: 582 RVA: 0x00013194 File Offset: 0x00011394
		private static void _Swap<Type>(ref Type[] lhs, ref Type[] rhs)
		{
			Type[] array = lhs;
			lhs = rhs;
			rhs = array;
		}

		// Token: 0x06000247 RID: 583 RVA: 0x000131AC File Offset: 0x000113AC
		public void Update()
		{
			if (this._boneTransformList == null || this._updateIValues == null || this._updateFValues == null || this._updateBoneFlagsList == null || this._updateBoneTransformList == null || this._updateBonePositionList == null || this._updateBoneRotationList == null || this._updateUserPositionList == null || this._updateUserRotationList == null || this._updateRigidBodyFlagsList == null || this._updateIKWeightList == null || this._updateMorphWeightList == null || this._modelTransform == null)
			{
				return;
			}
			if (this.model != null)
			{
				if (this.localWorld != null)
				{
					this.localWorld.SetGravity(this.model.bulletPhysics.worldProperty.gravityScale, this.model.bulletPhysics.worldProperty.gravityNoise, this.model.bulletPhysics.worldProperty.gravityDirection);
				}
				if (this.model.ikList != null)
				{
					for (int num = 0; num != this.model.ikList.Length; num++)
					{
						if (this.model.ikList[num] != null)
						{
							this.SetIKProperty(num, this.model.ikList[num].ikEnabled, this.model.ikList[num].ikWeight);
						}
					}
				}
				if (this.model.morphList != null && this.model.morphList.Length == this._updateMorphWeightList.Length)
				{
					for (int num2 = 0; num2 != this.model.morphList.Length; num2++)
					{
						this._updateMorphWeightList[num2] = this.model.morphList[num2]._updatedWeight;
					}
				}
				if (this.model.rigidBodyList != null)
				{
					for (int num3 = 0; num3 != this.model.rigidBodyList.Length; num3++)
					{
						if (this.model.rigidBodyList[num3] != null)
						{
							this.SetRigidBodyFreezed(num3, this.model.rigidBodyList[num3].freezed);
						}
					}
				}
			}
			int num4 = this._boneTransformList.Length;
			int num5 = 0;
			num5 |= ((!this.model.ikEnabled) ? 0 : 1);
			num5 |= ((!this.model.boneInherenceEnabled) ? 0 : 2);
			num5 |= ((!this.model.boneMorphEnabled) ? 0 : 4);
			num5 |= ((!this.model.fullBodyIKEnabled) ? 0 : 16);
			if (this.model != null)
			{
				float pphShoulderFixRateImmediately = this.model.pphShoulderFixRateImmediately;
				if (pphShoulderFixRateImmediately > 0f)
				{
					num5 |= 8;
					if (this._updateFValues[1] != pphShoulderFixRateImmediately)
					{
						this._updateFValues[1] = pphShoulderFixRateImmediately;
						this._isDirtyPreUpdate = true;
					}
				}
				MMD4MecanimBone[] boneList = this.model.boneList;
				if (boneList != null)
				{
					for (int num6 = 0; num6 != num4; num6++)
					{
						MMD4MecanimBone mmd4MecanimBone = boneList[num6];
						if (mmd4MecanimBone != null)
						{
							bool flag = (this._updateUserPositionIsValidList[num6 >> 5] >> num6 & 1U) != 0U;
							bool flag2 = (this._updateUserRotationIsValidList[num6 >> 5] >> num6 & 1U) != 0U;
							if (!mmd4MecanimBone._userPositionIsZero != flag)
							{
								this._isDirtyPreUpdate = true;
								if (mmd4MecanimBone._userPositionIsZero)
								{
									this._updateUserPositionIsValidList[num6 >> 5] &= ~(1U << num6);
									this._updateUserPositionList[num6] = Vector3.zero;
								}
								else
								{
									this._updateUserPositionIsValidList[num6 >> 5] |= 1U << num6;
									this._updateUserPositionList[num6] = mmd4MecanimBone._userPosition;
								}
							}
							else if (flag)
							{
								this._updateUserPositionList[num6] = mmd4MecanimBone._userPosition;
							}
							if (!mmd4MecanimBone._userRotationIsIdentity != flag2)
							{
								this._isDirtyPreUpdate = true;
								if (mmd4MecanimBone._userRotationIsIdentity)
								{
									this._updateUserRotationIsValidList[num6 >> 5] &= ~(1U << num6);
									this._updateUserRotationList[num6] = Quaternion.identity;
								}
								else
								{
									this._updateUserRotationIsValidList[num6 >> 5] |= 1U << num6;
									this._updateUserRotationList[num6] = mmd4MecanimBone._userRotation;
								}
							}
							else if (flag2)
							{
								this._updateUserRotationList[num6] = mmd4MecanimBone._userRotation;
							}
						}
					}
				}
			}
			if (this._isDirtyPreUpdate)
			{
				for (int num7 = 0; num7 != num4; num7++)
				{
					this._updateBoneFlagsList[num7] = 0;
				}
				if (this.model != null)
				{
					MMD4MecanimBone[] boneList2 = this.model.boneList;
					if (boneList2 != null && boneList2.Length == num4)
					{
						for (int num8 = 0; num8 != num4; num8++)
						{
							if (boneList2[num8] != null)
							{
								int humanBodyBones = boneList2[num8].humanBodyBones;
								if (humanBodyBones != -1)
								{
									switch (humanBodyBones)
									{
									case 11:
										this._updateBoneFlagsList[num8] |= 16777216;
										break;
									case 12:
										this._updateBoneFlagsList[num8] |= 50331648;
										break;
									case 13:
										this._updateBoneFlagsList[num8] |= 33554432;
										break;
									case 14:
										this._updateBoneFlagsList[num8] |= 67108864;
										break;
									}
								}
							}
							bool flag3 = (this._updateUserPositionIsValidList[num8 >> 5] >> num8 & 1U) != 0U;
							bool flag4 = (this._updateUserRotationIsValidList[num8 >> 5] >> num8 & 1U) != 0U;
							if (flag3)
							{
								this._updateBoneFlagsList[num8] |= 128;
							}
							if (flag4)
							{
								this._updateBoneFlagsList[num8] |= 256;
							}
						}
					}
				}
				bool flag5 = false;
				if (this.bulletMMDModel != null)
				{
					flag5 = true;
					this.bulletMMDModel.PreUpdate((uint)num5, this._updateBoneFlagsList, this._updateRigidBodyFlagsList, this._updateIKWeightList, this._updateMorphWeightList);
				}
				if (!flag5 && this.mmdModelPtr != IntPtr.Zero)
				{
					MMD4MecanimCommon.GCHValues<int> v = MMD4MecanimCommon.MakeGCHValues<int>(this._updateBoneFlagsList);
					MMD4MecanimCommon.GCHValues<int> v2 = MMD4MecanimCommon.MakeGCHValues<int>(this._updateRigidBodyFlagsList);
					MMD4MecanimCommon.GCHValues<float> v3 = MMD4MecanimCommon.MakeGCHValues<float>(this._updateIKWeightList);
					MMD4MecanimCommon.GCHValues<float> v4 = MMD4MecanimCommon.MakeGCHValues<float>(this._updateMorphWeightList);
					MMD4MecanimCommon.GCHValues<int> v5 = MMD4MecanimCommon.MakeGCHValues<int>(this._updateFullBodyIKFlagsList);
					MMD4MecanimCommon.GCHValues<float> v6 = MMD4MecanimCommon.MakeGCHValues<float>(this._updateFullBodyIKWeightList);
					MMD4MecanimBulletPhysics._PreUpdateMMDModel(this.mmdModelPtr, num5, v, v.length, v2, v2.length, v3, v3.length, v4, v4.length, v5, v6, v6.length);
					v6.Free();
					v5.Free();
					v4.Free();
					v3.Free();
					v2.Free();
					v.Free();
				}
			}
			for (int num9 = 0; num9 != num4; num9++)
			{
				Transform transform = this._boneTransformList[num9];
				if (transform != null)
				{
					if ((this._updateBoneFlagsList[num9] & 1) != 0)
					{
						this._updateBoneTransformList[num9] = transform.localToWorldMatrix;
					}
					for (int i = 0; i < 16; i++)
					{
						Matrix4x4[] updateBoneTransformList = this._updateBoneTransformList;
						int num10 = num9;
						ref Matrix4x4 ptr = ref updateBoneTransformList[num10];
						int index;
						updateBoneTransformList[num10][index = i] = ptr[index] / this.model.transform.localScale.x;
					}
					if ((this._updateBoneFlagsList[num9] & 2) != 0)
					{
						this._updateBonePositionList[num9] = transform.localPosition;
					}
					if ((this._updateBoneFlagsList[num9] & 4) != 0)
					{
						this._updateBoneRotationList[num9] = transform.localRotation;
					}
				}
			}
			Matrix4x4 localToWorldMatrix = this._modelTransform.localToWorldMatrix;
			if (this.bulletMMDModel != null)
			{
				this.bulletMMDModel.Update((uint)num5, this._updateIValues, this._updateFValues, ref localToWorldMatrix, this._updateBoneFlagsList, this._updateBoneTransformList, this._updateBonePositionList, this._updateBoneRotationList, this._updateUserPositionList, this._updateUserRotationList, this._updateRigidBodyFlagsList, this._updateIKWeightList, this._updateMorphWeightList);
				return;
			}
			if (this.mmdModelPtr != IntPtr.Zero)
			{
				MMD4MecanimCommon.GCHValues<int> v7 = MMD4MecanimCommon.MakeGCHValues<int>(this._updateIValues);
				MMD4MecanimCommon.GCHValues<float> v8 = MMD4MecanimCommon.MakeGCHValues<float>(this._updateFValues);
				MMD4MecanimCommon.GCHValue<Matrix4x4> v9 = MMD4MecanimCommon.MakeGCHValue<Matrix4x4>(ref localToWorldMatrix);
				MMD4MecanimCommon.GCHValues<int> v10 = MMD4MecanimCommon.MakeGCHValues<int>(this._updateBoneFlagsList);
				MMD4MecanimCommon.GCHValues<Matrix4x4> v11 = MMD4MecanimCommon.MakeGCHValues<Matrix4x4>(this._updateBoneTransformList);
				MMD4MecanimCommon.GCHValues<Vector3> v12 = MMD4MecanimCommon.MakeGCHValues<Vector3>(this._updateBonePositionList);
				MMD4MecanimCommon.GCHValues<Quaternion> v13 = MMD4MecanimCommon.MakeGCHValues<Quaternion>(this._updateBoneRotationList);
				MMD4MecanimCommon.GCHValues<Vector3> v14 = MMD4MecanimCommon.MakeGCHValues<Vector3>(this._updateUserPositionList);
				MMD4MecanimCommon.GCHValues<Quaternion> v15 = MMD4MecanimCommon.MakeGCHValues<Quaternion>(this._updateUserRotationList);
				MMD4MecanimCommon.GCHValues<int> v16 = MMD4MecanimCommon.MakeGCHValues<int>(this._updateRigidBodyFlagsList);
				MMD4MecanimCommon.GCHValues<float> v17 = MMD4MecanimCommon.MakeGCHValues<float>(this._updateIKWeightList);
				MMD4MecanimCommon.GCHValues<float> v18 = MMD4MecanimCommon.MakeGCHValues<float>(this._updateMorphWeightList);
				MMD4MecanimCommon.GCHValues<int> v19 = MMD4MecanimCommon.MakeGCHValues<int>(this._updateFullBodyIKFlagsList);
				MMD4MecanimCommon.GCHValues<float> v20 = MMD4MecanimCommon.MakeGCHValues<float>(this._updateFullBodyIKTransformList);
				MMD4MecanimCommon.GCHValues<float> v21 = MMD4MecanimCommon.MakeGCHValues<float>(this._updateFullBodyIKWeightList);
				MMD4MecanimBulletPhysics._UpdateMMDModel(this.mmdModelPtr, num5, v7, v7.length, v8, v8.length, v9, v10, v11, v12, v13, v14, v15, v10.length, v16, v16.length, v17, v17.length, v18, v18.length, v19, v20, v21, v21.length);
				v21.Free();
				v20.Free();
				v19.Free();
				v18.Free();
				v17.Free();
				v16.Free();
				v15.Free();
				v14.Free();
				v13.Free();
				v12.Free();
				v11.Free();
				v10.Free();
				v9.Free();
				v8.Free();
				v7.Free();
			}
		}

		// Token: 0x06000248 RID: 584 RVA: 0x00013C9C File Offset: 0x00011E9C
		public void LateUpdate(float deltaTime)
		{
			if (this._boneTransformList == null || this._updateBoneTransformList == null || this._updateBoneFlagsList == null || this._updateBonePositionList == null || this._updateBoneRotationList == null)
			{
				return;
			}
			if (this.localWorld != null)
			{
				this.localWorld.Update(deltaTime);
			}
			int num = 0;
			int[] array = null;
			Vector3[] array2 = null;
			Quaternion[] array3 = null;
			int[] array4 = null;
			MMD4MecanimInternal.Bullet.MMDModel.UpdateData updateData = null;
			if (this.bulletMMDModel != null)
			{
				updateData = this.bulletMMDModel.LateUpdate();
				if (updateData != null)
				{
					num = (int)updateData.lateUpdateFlags;
					array = updateData.lateUpdateBoneFlagsList;
					array2 = updateData.lateUpdateBonePositionList;
					array3 = updateData.lateUpdateBoneRotationList;
					array4 = updateData.lateUpdateMeshFlagsList;
				}
			}
			if (this.mmdModelPtr != IntPtr.Zero)
			{
				if (this._lateUpdateBoneFlagsList == null || this._lateUpdateBonePositionList == null || this._lateUpdateBoneRotationList == null)
				{
					int num2 = (this._boneTransformList == null) ? 0 : this._boneTransformList.Length;
					this._lateUpdateBoneFlagsList = new int[num2];
					this._lateUpdateBonePositionList = new Vector3[num2];
					this._lateUpdateBoneRotationList = new Quaternion[num2];
				}
				if (this._lateUpdateMeshFlagsList == null)
				{
					int num3 = (!(this.model != null)) ? 0 : this.model._skinnedMeshCount;
					this._lateUpdateMeshFlagsList = new int[num3];
				}
				MMD4MecanimCommon.GCHValues<int> v = MMD4MecanimCommon.MakeGCHValues<int>(this._lateUpdateBoneFlagsList);
				MMD4MecanimCommon.GCHValues<Vector3> v2 = MMD4MecanimCommon.MakeGCHValues<Vector3>(this._lateUpdateBonePositionList);
				MMD4MecanimCommon.GCHValues<Quaternion> v3 = MMD4MecanimCommon.MakeGCHValues<Quaternion>(this._lateUpdateBoneRotationList);
				MMD4MecanimCommon.GCHValues<int> v4 = MMD4MecanimCommon.MakeGCHValues<int>(this._lateUpdateMeshFlagsList);
				num = MMD4MecanimBulletPhysics._LateUpdateMMDModel(this.mmdModelPtr, IntPtr.Zero, 0, IntPtr.Zero, 0, v, v2, v3, this._lateUpdateBoneFlagsList.Length, v4, v4.length, IntPtr.Zero, 0);
				v4.Free();
				v3.Free();
				v2.Free();
				v.Free();
				array = this._lateUpdateBoneFlagsList;
				array2 = this._lateUpdateBonePositionList;
				array3 = this._lateUpdateBoneRotationList;
				array4 = this._lateUpdateMeshFlagsList;
			}
			if ((num & 1) != 0 && array != null && array2 != null && array3 != null)
			{
				int num4 = this._boneTransformList.Length;
				for (int num5 = 0; num5 != num4; num5++)
				{
					Transform transform = this._boneTransformList[num5];
					if (transform != null && (array[num5] & 1) != 0)
					{
						if ((array[num5] & 2) != 0)
						{
							transform.localPosition = array2[num5];
						}
						if ((array[num5] & 4) != 0)
						{
							transform.localRotation = array3[num5];
						}
					}
				}
			}
			if ((num & 2) != 0 && array4 != null)
			{
				if (this.bulletMMDModel != null && updateData != null)
				{
					MMD4MecanimInternal.Bullet.MMDModel.LateUpdateMeshData[] lateUpdateMeshDataList = updateData.lateUpdateMeshDataList;
					int cloneMeshCount = this.model._cloneMeshCount;
					if (lateUpdateMeshDataList != null && lateUpdateMeshDataList.Length == cloneMeshCount && array4.Length == cloneMeshCount)
					{
						for (int num6 = 0; num6 != cloneMeshCount; num6++)
						{
							int num7 = array4[num6];
							if ((num7 & 3) != 0)
							{
								Vector3[] vertices = null;
								Vector3[] normals = null;
								if (lateUpdateMeshDataList[num6] != null)
								{
									if ((num7 & 1) != 0)
									{
										vertices = lateUpdateMeshDataList[num6].vertices;
									}
									if ((num7 & 2) != 0)
									{
										normals = lateUpdateMeshDataList[num6].normals;
									}
									this.model._UploadMeshVertex(num6, vertices, normals);
								}
							}
						}
					}
					return;
				}
				if (this.mmdModelPtr != IntPtr.Zero)
				{
					int cloneMeshCount2 = this.model._cloneMeshCount;
					for (int num8 = 0; num8 != cloneMeshCount2; num8++)
					{
						int num9 = array4[num8];
						if ((num9 & 3) != 0)
						{
							MMD4MecanimModel.CloneMesh cloneMesh = this.model._GetCloneMesh(num8);
							if (cloneMesh != null)
							{
								Vector3[] array5 = null;
								Vector3[] array6 = null;
								if ((num9 & 1) != 0)
								{
									array5 = cloneMesh.vertices;
								}
								if ((num9 & 2) != 0)
								{
									array6 = cloneMesh.normals;
								}
								MMD4MecanimCommon.GCHValues<Vector3> v5 = MMD4MecanimCommon.MakeGCHValues<Vector3>(array5);
								MMD4MecanimCommon.GCHValues<Vector3> v6 = MMD4MecanimCommon.MakeGCHValues<Vector3>(array6);
								int num10 = MMD4MecanimBulletPhysics._LateUpdateMeshMMDModel(this.mmdModelPtr, num8, v5, v6, v5.length);
								v6.Free();
								v5.Free();
								if (num10 != 0)
								{
									this.model._UploadMeshVertex(num8, array5, array6);
								}
							}
						}
					}
				}
			}
		}

		// Token: 0x040002BA RID: 698
		public MMD4MecanimBulletPhysics.World localWorld;

		// Token: 0x040002BB RID: 699
		public MMD4MecanimModel model;

		// Token: 0x040002BC RID: 700
		public MMD4MecanimInternal.Bullet.MMDModel bulletMMDModel;

		// Token: 0x040002BD RID: 701
		public IntPtr mmdModelPtr;

		// Token: 0x040002BE RID: 702
		private Transform _modelTransform;

		// Token: 0x040002BF RID: 703
		private bool _physicsEnabled;

		// Token: 0x040002C0 RID: 704
		private Transform[] _boneTransformList;

		// Token: 0x040002C1 RID: 705
		private int[] _updateRigidBodyFlagsList;

		// Token: 0x040002C2 RID: 706
		private float[] _updateIKWeightList;

		// Token: 0x040002C3 RID: 707
		private float[] _updateMorphWeightList;

		// Token: 0x040002C4 RID: 708
		private float[] _ikWeightList;

		// Token: 0x040002C5 RID: 709
		private bool[] _ikDisabledList;

		// Token: 0x040002C6 RID: 710
		private int[] _fullBodyIKBoneIDList;

		// Token: 0x040002C7 RID: 711
		private Vector3[] _fullBodyIKPositionList;

		// Token: 0x040002C8 RID: 712
		private Quaternion[] _fullBodyIKRotationList;

		// Token: 0x040002C9 RID: 713
		private Vector3 _lossyScale = Vector3.one;

		// Token: 0x040002CA RID: 714
		private int[] _updateIValues;

		// Token: 0x040002CB RID: 715
		private float[] _updateFValues;

		// Token: 0x040002CC RID: 716
		private int[] _updateBoneFlagsList;

		// Token: 0x040002CD RID: 717
		private Matrix4x4[] _updateBoneTransformList;

		// Token: 0x040002CE RID: 718
		private Vector3[] _updateBonePositionList;

		// Token: 0x040002CF RID: 719
		private Quaternion[] _updateBoneRotationList;

		// Token: 0x040002D0 RID: 720
		private Vector3[] _updateUserPositionList;

		// Token: 0x040002D1 RID: 721
		private Quaternion[] _updateUserRotationList;

		// Token: 0x040002D2 RID: 722
		private uint[] _updateUserPositionIsValidList;

		// Token: 0x040002D3 RID: 723
		private uint[] _updateUserRotationIsValidList;

		// Token: 0x040002D4 RID: 724
		private int[] _updateFullBodyIKFlagsList;

		// Token: 0x040002D5 RID: 725
		private float[] _updateFullBodyIKTransformList;

		// Token: 0x040002D6 RID: 726
		private float[] _updateFullBodyIKWeightList;

		// Token: 0x040002D7 RID: 727
		private int[] _lateUpdateBoneFlagsList;

		// Token: 0x040002D8 RID: 728
		private Vector3[] _lateUpdateBonePositionList;

		// Token: 0x040002D9 RID: 729
		private Quaternion[] _lateUpdateBoneRotationList;

		// Token: 0x040002DA RID: 730
		private int[] _lateUpdateMeshFlagsList;

		// Token: 0x040002DB RID: 731
		private bool _isDirtyPreUpdate = true;

		// Token: 0x040002DC RID: 732
		public const int FullBodyIKTargetMax = 36;

		// Token: 0x02000053 RID: 83
		public enum UpdateIValues
		{
			// Token: 0x040002DE RID: 734
			AnimationHashName,
			// Token: 0x040002DF RID: 735
			Max
		}

		// Token: 0x02000054 RID: 84
		public enum UpdateFValues
		{
			// Token: 0x040002E1 RID: 737
			AnimationTime,
			// Token: 0x040002E2 RID: 738
			PPHShoulderFixRate,
			// Token: 0x040002E3 RID: 739
			Max
		}

		// Token: 0x02000055 RID: 85
		[Flags]
		public enum LateUpdateMeshFlags
		{
			// Token: 0x040002E5 RID: 741
			Vertices = 1,
			// Token: 0x040002E6 RID: 742
			Normals = 2
		}

		// Token: 0x02000056 RID: 86
		[Flags]
		public enum UpdateFlags
		{
			// Token: 0x040002E8 RID: 744
			IKEnabled = 1,
			// Token: 0x040002E9 RID: 745
			BoneInherenceEnabled = 2,
			// Token: 0x040002EA RID: 746
			BoneMorphEnabled = 4,
			// Token: 0x040002EB RID: 747
			PPHShoulderEnabled = 8,
			// Token: 0x040002EC RID: 748
			FullBodyIKEnabled = 16
		}

		// Token: 0x02000057 RID: 87
		[Flags]
		public enum UpdateBoneFlags
		{
			// Token: 0x040002EE RID: 750
			WorldTransform = 1,
			// Token: 0x040002EF RID: 751
			Position = 2,
			// Token: 0x040002F0 RID: 752
			Rotation = 4,
			// Token: 0x040002F1 RID: 753
			UserPosition = 128,
			// Token: 0x040002F2 RID: 754
			UserRotation = 256,
			// Token: 0x040002F3 RID: 755
			SkeletonMask = -16777216,
			// Token: 0x040002F4 RID: 756
			SkeletonLeftShoulder = 16777216,
			// Token: 0x040002F5 RID: 757
			SkeletonLeftUpperArm = 33554432,
			// Token: 0x040002F6 RID: 758
			SkeletonRightShoulder = 50331648,
			// Token: 0x040002F7 RID: 759
			SkeletonRightUpperArm = 67108864,
			// Token: 0x040002F8 RID: 760
			UserTransform = 384
		}

		// Token: 0x02000058 RID: 88
		[Flags]
		public enum UpdateRigidBodyFlags
		{
			// Token: 0x040002FA RID: 762
			Freezed = 1
		}

		// Token: 0x02000059 RID: 89
		[Flags]
		public enum LateUpdateFlags
		{
			// Token: 0x040002FC RID: 764
			Bone = 1,
			// Token: 0x040002FD RID: 765
			Mesh = 2
		}

		// Token: 0x0200005A RID: 90
		[Flags]
		public enum LateUpdateBoneFlags
		{
			// Token: 0x040002FF RID: 767
			LateUpdated = 1,
			// Token: 0x04000300 RID: 768
			Position = 2,
			// Token: 0x04000301 RID: 769
			Rotation = 4
		}
	}
}
